//WAP to input 10 number in array & calculate sum & average #include<stdio.h> #include<conio.h> void main() { int i,n[10],sum=0,avg=0; clrscr(); printf("Enter 10 element in array:"); for(i=0;i<10;i++) scanf("%d",&n[i]); for(i=0;i<10;i++) sum = sum + n[i]; avg = sum/10; printf("Sum = %d",sum); printf("Avg = %d",avg); getch(); }
// WAP to enter three numbers and find middle number among them. #include<stdio.h> #include<conio.h> void main ( ) { int a , b , c ; clrscr ( ) ; printf ( "Enter three number: \n " ) ; scanf ( "%d%d%d" ,& a ,& b ,& c ) ; if ( ( a > b && a < c ) || ( a > c && a < b ) ) printf ( "%d is middle number" , a ) ; else if ( ( b > a && b < c ) || ( b > c && b < a ) ) printf ( "%d is middle number" , b ) ; else printf ( "%d is middle number" , c ) ; getch ( ) ; } Output:
Comments
Post a Comment