0 votes
336 views
in C programming by (98.9k points)
edited
C Program to Find the Sum of First N Natural Numbers

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
#include <stdio.h>
#include <conio.h>
 
int main(){
      
    int numberCount=0, number, counter, sum=0;
     
    printf("Enter the number of integers to add: ");
    scanf("%d",&numberCount);
     
    printf("Enter %d numbers seperated by space \n", numberCount);
    for(counter = 0; counter < numberCount; counter++){
        scanf("%d", &number);
        sum = sum + number;
    }
    printf("SUM = %d", sum);
    getch();
    return 0;
}

 

Related questions

0 votes
1 answer 437 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

561 users

...