C program to find the sum of first 50 natural numbers using for loop

by Nideesh C on April 13, 2011 · 0 comments

in C Programming




/* C program to find the sum of first 50 natural numbers using for loop */

#include <stdio.h>

void main()
{
int  num,sum=0;

for(num = 1; num <= 50; num++)
{
sum = sum + num;
}

printf(“Sum = %4d\n”, sum);
}

/*—————————
Output
Sum = 1275
—————————-*/                 /* End of main() */

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. Write a C program to find the sum of ‘N’ natural numbers
  2. C program to read N integers (zero, +ve and -ve) into an array A and to a) Find the sum of negative numbers b) Find the sum of positive numbers and c) Find the average of all input numbers Output the various results computed with proper headings
  3. C program to find the sum of odd numbers and sum of even numbers from 1 to N. Output the computed sums on two different lines with suitable headings
  4. C program to find the number of integers divisible by 5 between the given range N1 and N2, where N1 < N2 and are integers. Also find the sum of all these integer numbers that divisible by 5 and output the computed results
  5. C program to read a matrix A (MxN) and to find the following using functions a) Sum of the elements of each row b) Sum of the elements of each column c) Find the sum of all the elements of the matrix Output the computed results with suitable headings

Leave a Comment

Previous post:

Next post: