Write a c programme to find some of the n natural numbers
Answers
C Program to Find the Sum of First N Natural Numbers
This C Program calculates the sum of first N natural numbers.
Here is source code of the C program to calculate the sum of first N natural numbers. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C program to find the sum of 'N' natural numbers
*/
#include <stdio.h>
void main()
{
int i, num, sum = 0;
printf("Enter an integer number \n");
scanf ("%d", &num);
for (i = 1; i <= num; i++)
{
sum = sum + i;
}
printf ("Sum of first %d natural numbers = %d\n", num, sum);
}
$ cc pgm3.c
$ a.out
Enter an integer number
1300
Sum of first 1300 natural numbers = 845650
$ a.out
Enter an integer number
15
Sum of first 15 natural numbers = 120
HOPE YOU UNDERSTAND #SJSINGH16
MARK THE ANSWER AS BRAINLIEST