pages

Wednesday, 19 May 2021

c-programming to print the sum of even and odd number in 10 numbers by using array | c-programming

 program to print the sum of even and odd number in 10 numbers in array in c-programming

In this program we will now takes 10 numbers form the user and print the sum of even and odd number and also print the even and odd in c-programming.

#include<stdio.h>
#include<conio.h>
void main()
{
         int a[10],i,even,odd,sum=0,evensum=0,oddsum=0;
         printf("enter the 10 number:-");
         for(i=0;i<=9;i++){
                  scanf("%d",&a[i]);
         }
         for(i=0;i<=9;i++){
                  sum=sum+a[i];
                  if(a[i]%2==0){
                           printf("even number is %d\n",a[i]);
                           evensum=evensum+a[i];
                  }
                  else{
                           printf("odd number is %d\n",a[i]);
                           oddsum=oddsum+a[i];
                  }
         }
         printf("\n the sum of even number is %d",evensum);
         printf("\n the sum of odd number is %d",oddsum);
         printf("\n the sum of the number is %d",sum);
         getch();
}

output:-



For more c-programming:-


















No comments:

Post a Comment