Smallest 3 Ints - int small small=a if(b<small small=b if(c<small small=c return small(shorter way if(a<=b&& a<=c return a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//This program finds the smallest of 3 ints #include <stdio.h> int findsmall(int,int,int); void main() { int n1,n2,n3,small; printf("Enter 3 values "); scanf("%d%d%d",&n1,&n2,&n3); small=findsmall(n1,n2,n3); printf("Smallest is %d\n",small); } int findsmall(int a,int b,int c)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { int small; small=a; if(b<small) small=b; if(c<small) small=c; return small; /* (shorter way) if(a<=b && a<=c) return a; if(b<=a && b<=c) return b; return c; */ } /* Enter 3 values 57 12 63 Smallest is 12 Press any key to continue . . . */...
View Full Document

This note was uploaded on 10/05/2011 for the course CS 36 taught by Professor Sethhochwald during the Spring '09 term at Irvine Valley College.

Ask a homework question - tutors are online