Advertisement
adventuretimeh

es n2

Feb 13th, 2020
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 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. //leggere una sequenza di numeri pari fino a che non si legge zero calcolare la somma e la media e visualizzare
  6. int main(int argc, char *argv[]) {
  7.     int somma,numero,conta;
  8.     float media;
  9.     somma=0;
  10.     conta=0;
  11.     media=0.00;
  12.     do{
  13.         printf("numero");
  14.         scanf("%d",&numero);
  15.     }while(numero%2!=0);
  16.    
  17.     while(numero!=0)
  18.     {
  19.        
  20.         somma=somma+numero;
  21.         conta=conta+1;
  22.         do{
  23.              printf("numero");
  24.              scanf("%d",&numero);
  25.           }while(numero%2!=0);
  26.     }
  27.     somma=somma+numero;
  28.     media=(float)somma/conta;
  29.     printf("\nmedia %6.2f",media);
  30.     printf("\nsomma %d",somma);
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement