xDefo

Programma somma n numeri

Oct 8th, 2020 (edited)
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. void main(void)
  4. {
  5.     int n=0;
  6.     int somma=0;
  7.     int media=0;
  8.     printf("Dammi il numero di valori che vuoi sommare: ");
  9.     scanf("%d",&n);
  10.     for (int i=1;i<=n;i++)
  11.     {
  12.         int addendo=0;
  13.         printf("Dammi il %d° addendo: ",i);
  14.         scanf("%d",&addendo);
  15.         somma+=addendo;
  16.     }
  17.     printf("La somma dei numeri è: %d\n",somma);
  18.  
  19. }
Add Comment
Please, Sign In to add comment