Advertisement
Joao_Joao

Questão 2 Lista de Exercícios IFPB

Apr 25th, 2022
570
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.   int x, p, sum = 0, sum_pesos = 0, i = 1;
  5.   for(;i<=3;++i) {
  6.     printf("Digite o valor do numero %d: ", i);
  7.     scanf("%d", &x);
  8.     printf("Digite o peso do numero %d: ", i);
  9.     scanf("%d", &p);
  10.     sum += x * p, sum_pesos += p;
  11.   }
  12.   printf("A media aritmetica dos 3 numeros eh: %.2lf\n", (double)sum / sum_pesos);
  13.  
  14.   return 0;
  15. }
Advertisement
RAW Paste Data Copied
Advertisement