You are on page 1of 1

//sum of even nos.

#include<iostream.h> #include<conio.h> void main() { int i,sum=0,sqsum=0; clrscr(); for(i=1;i<31;i++) { if(i%2==0) {sum+=i; sqsum+=(i*i); } } cout<<"sum of first 15 even no.="<<sum; cout<<"\n and sum of their squares="<<sqsum; getch(); }

output
sum of first 15 even no.=240 and sum of their squares=4960

You might also like