rabbinur

to add n int by array

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