Friday, April 16, 2010

Sum of even and odd numbers from 10 numbers

#include<iostream.h>
#include<conio.h>
 void main()
 {
 clrscr();
 int n,l,e,o;
 e=0;
 o=0;
 cout<<"enter 10 nos.";
 for(l=1;l<=10;l++)
 {
 cin>>n;
 if(n%2==0)
 e=e+n;
 else
 o=o+n;
 }
 cout<<"sum of even nos."<<e;
 cout<<"sum of odd nos."<<o;
 getch();
 }

No comments:

Post a Comment