Program No : 14 :

Write a program in C to sum of M to N numbers ?

       program no  :14.
purpose : sum of M to N numbers ie 23 to 56, 34 to 700 etc..

#include <"stdio.h">
void main()
{
	int sum=0,M,N;

	scanf("%d%d",&M,&N);

	 while (M<=N)
	 {
		 sum=sum+M;

		 M=M+1;
	 }

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

} 
Back