February 25, 2019

C Program to Add n Number of Times

The following is a C Program to Add n Number of Times on screen after taking input from user. Let's get started.

C Program To Add n Number of Times
C Program To Add n Number of Times

Overview:


Commands

scanf() function is used to obtain input and printf() function is used to print the string on the screen.

Program

#include<stdio.h>
#include<conio.h>
int main()
{
      int n,sum=0,i,value;
      clrscr();
      printf("How many integers you want to add?\n");
      scanf("%d", &n);
      printf("Enter %d integers\n",n); 
      for(i=1;i<=n;i++) 
      {         
               scanf("%d",&value); 
               sum+=value;
      }
      printf("Sum of entered integers = %d\n",sum);
      getch();
}



Output

Add n times output
Add n times Output


All programs compiled in this post are compiled in AnDOSBox.

Books I Prefer:






I hope this article was helpful to understand C Program to Add n Number of Times! Comment below, if you've got any question. Head back soon for another interesting article on C Programming.