c + n
Chat with our AI personalities
void main () { int no1, sum, n; clrscr() sum = 0; n = 1; printf("\n enter the number to which sum is to be generated"); scanf("%d",&no1); while(n<=no1) { sum=sum+n; n=n+1 } printf("\n the sum of %d = %d, no1, sum"); getch (); }
/*mycfiles.wordpress.com To Calculate Sum & Average of 4 no.*/ #include<stdio.h> #include<conio.h> void main() { float a,b,c,d,sum,avg; clrscr(); printf("Enter the 4 nos.\n\n"); scanf("%f%f%f%f",&a,&b,&c,&d); sum=a+b+c+d; avg=(a+b+c+d)/4; printf("\nSum is= %f\nAverage is= %f",sum,avg); getch(); }
The sum of n and 5 is n+ 5
Find the Sum to n terms of the series 5 5+55+555+ +n Terms
#include<stdio.h> #include<conio.h> void main() { int c=1,i; unsigned int s=0; clrscr(); for(i=1,(i<=15;i++)) { if(i%2==0) { s=s+i; c=c+i; } } printf("/n sum of the first 15 even numbers is%d",s); printf("/n square of the sum is: %d",(s*s)); getch(); }