google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a c program to find the sum of even and odd numbers in an array - 2nd puc computer science

Write a c program to find the sum of even and odd numbers in an array

Write a c program to find the sum of even and odd numbers in an array

#include<stdio.h>

#include<conio.h>

void main()

{

int a[10],i,esum=0,osum=0,n;

clrscr();

printf("How many elements?");

scanf("%d",&n);

printf("Enter the elements\n");

for(i=0;i<n;i++)

scanf("%d",&a[i]);

for(i=0;i<n;i++)

if(a[i]%2==0)

esum=esum+a[i];

else

osum=osum+a[i];

printf("even sum=%d\n",esum);

printf("odd sum=%d",osum);

getch();

}

Write a c program to find the sum of even and odd numbers in an array Write a c program to find the sum of even and odd numbers in an array Reviewed by Vision Academy on December 26, 2021 Rating: 5

No comments:

CheckOut

Powered by Blogger.