adventuretimeh

la somma di più numeri

Oct 5th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5. // IL PROGRAMMA FUNZIONA SE VI DICE [Warning] unknown escape sequence: '\040' NON VI PREOCUPATE  BASTA FARE COMPILA ED ESEGUI
  6.  
  7. int main(int argc, char *argv[]) {
  8.     int contatore, somma, numero, i;
  9.    
  10.     do{
  11.         printf("\n dimmi quanti numeri devo sommare");
  12.         scanf("%d",&contatore);
  13.     }while(contatore<=0);
  14.    
  15.     i=0;
  16.     somma=0;
  17.     do {
  18.         printf("\n dammi un numero");
  19.         scanf("%d",&numero);
  20.         somma=somma+numero;
  21.         i=i+1;
  22.     }while(i<contatore);
  23.     printf("\ la somma vale = %d",somma);
  24.    
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment