rabbinur

add n integers.CPP

Aug 3rd, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4.  
  5. int main()
  6. {
  7.    int n, sum = 0, c, value;
  8.    system ("cls");
  9.    printf("Enter the number of integers you want to add\n");
  10.    scanf("%d", &n);
  11.  
  12.    printf("Enter %d integers\n",n);
  13.  
  14.    for (c = 1; c <= n; c++)
  15.    {
  16.       scanf("%d",&value);
  17.       sum = sum + value;
  18.    }
  19.  
  20.    printf("Sum of entered integers = %d\n",sum);
  21.  
  22.    getch();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment