Skip to content

Instantly share code, notes, and snippets.

@snadahalli
Created November 6, 2013 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snadahalli/7340711 to your computer and use it in GitHub Desktop.
Save snadahalli/7340711 to your computer and use it in GitHub Desktop.
C Program to read ten integers from the keyboards and print the sum of even and odd numbers.
/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
/*WAP to read ten integers from the keyboards and print the sum of even and odd numbers.*/
#include<stdio.h>
int main()
{
int a[10];
int i,sumeven=0,sumodd=0;
printf("Enter ten Integers:\n");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<10;i++)
{
if(a[i]%2==0)
{
sumeven=sumeven+a[i];
}
else
{
sumodd=sumodd+a[i];
}
}
printf("\nSum of even numbers is: %d", sumeven);
printf("\nSum of odd numbers is: %d", sumodd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment