#include<stdio.h> main() { int arr[5]={2,5,3,4,1}; for(int i=0;i<=4;i++) printf("%d ",arr[i]); }
2 5 3 4 1
#include<stdio.h> main() { int a[10]={5,2,4,8,10,12,3,15,3,6}; for(int i=0;i<=9;i++) printf("%d ",a[i]); }
5 2 4 8 10 12 3 15 3 6
#include<stdio.h> main() { int s=0; int a[10]={5,2,4,8,10,12,3,15,3,6}; for(int i=0;i<=9;i++) s=s+a[i]; printf("Sum is %d ",s); }
Sum is 68
#include<stdio.h> main() { int s=0; int a[10]={5,2,4,8,10,12,3,15,3,6}; for(int i=0;i<=9;i++) { if(a[i]%2==0) s=s+a[i]; } printf("Sum of even numbers is %d ",s); }
Sum of even numbers is 42
#include<stdio.h> main() { int s=0; int a[10]={5,2,4,8,10,12,3,15,3,6}; for(int i=0;i<=9;i++) { if(a[i]%2!=0) s=s+a[i]; } printf("Sum of odd number is %d ",s); }
Sum of odd number is 26
#include<stdio.h> main() { int a[10]; int s=0; printf("Enter 10 no: \n"); for(int i=0;i<10;i++) scanf("%d",&a[i]); printf("Array values are:\n") for(int i=0;i<10;i++) printf("%d ",a[i]); }
Enter 10 nos: 2 3 4 5 6 1 9 8 7 0 Array values are: 2 3 4 5 6 1 9 8 7 0
#include<stdio.h> main() { int a[10],s=0; printf("Enter 10 nos:"); for(int i=0;i<10;i++) { scanf("%d",&a[i]); s=s+a[i]; } printf("Sum is %d",s); }
Enter 10 nos: 2 3 5 6 4 6 5 2 10 8 Sum is 51
#include<stdio.h> main() { int a[10]; int s=0; printf("Enter a number: \n"); for(int i=0;i<10;i++) { scanf("%d",&a[i]); if(a[i]%2==0) s=s+a[i]; } printf("Sum of all even no is %d",s); }
Enter 10 number 10 21 3 8 15 14 12 6 7 15 Sum of all even no is 50
#include<stdio.h> main() { int a[10],s=0; printf("Enter 10 numbers: \n"); for(int i=0;i<10;i++) { scanf("%d",&a[i]); if(a[i]%2!=0) s=s+a[i]; } printf("Sum of all odd no is %d",s); }
Enter 10 numbers: 1 2 3 4 5 6 7 8 9 0 Sum of all odd no is 25
#include<stdio.h> main() { int a[7],s=0,i; float Avg; printf("Enter temperature 7 days\n"); for(i=0;i<=6;i++) { scanf("%d",&a[i]); s=s+a[i]; Avg=s/7.0; } printf("Average temperature is %f",Avg); }
Enter temperature 7 days 21 23 24 25 26 21 20 Average temperature is 22.8571
#include<stdio.h> main() { int a[10],s1=0,s2=0,i; printf("Enter 10 number:\n"); for(i=0;i<=9;i++) scanf("%d",&a[i]); for(i=0;i<=4;i++) s1=s1+a[i]; for(i=5;i<=9;i++) s2=s2+a[i]; if(s1==s2) printf("sum is equal"); else printf("sum is not equal"); }
Enter 10 number: 8 5 6 3 7 4 5 9 6 4 sum is not equal
#include<stdio.h> main() { int a[10],c=0,i; printf("Enter 10 numbers:\n"); for(i=0;i<=9;i++) { scanf("%d",&a[i]); if(a[i]<0) c=c+1; } printf("Negative Number are %d",c); }
Enter 10 numbers: 8 5 -6 3 7 -4 5 -9 6 4 Negative Number are 3
#include<stdio.h> main() { int a[10],c=0,i; printf("Enter 10 numbers:\n"); for(i=0;i<=9;i++) { scanf("%d",&a[i]); if(a[i]%2==0) c=c+1; } printf("Even Number are %d",c); }
Enter 10 numbers: 8 5 6 3 7 4 5 9 6 4 Even Number are 5
#include<stdio.h> main() { int a[10],c=0,i; printf("Enter 10 numbers:\n"); for(i=0;i<=9;i++) { scanf("%d",&a[i]); if(a[i]!=0) c=c+1; } printf("Non zero number are %d",c); }
Enter 10 numbers: 8 0 6 3 7 0 5 9 0 4 Non zero number are 7
#include<stdio.h> main() { int a[10],G,i; printf("Enter 10 numbers:\n"); for(i=0;i<=9;i++) scanf("%d",&a[i]); G=a[0]; for(i=1;i<=9;i++) { if(a[i]>G) G=a[i]; } printf("Greatest number is %d",G); }
Enter 10 numbers: 3 5 4 2 10 6 12 7 9 8 Greatest number is 12