1
On reading the variable at the end to display the value, displays a trash, here is the statement along with my code.
Make a program that receives the age, height and weight of five people, calculate and show:
- The number of persons over the age of 50;
- The average height of people aged between 10 and 20;
- The percentage of persons weighing less than 40 kg among 5 persons
#include <stdio.h>
int main ()
{
int idade , cont50,md, espantalho, mdpeso, i;
float peso, altura ;
for (i = 1 ; i <3 ; i++)
{
printf ("\nDigite a sua idade :") ;
scanf ("%d", &idade) ;
printf ("Digite a sua altura :") ;
scanf ("%f", &altura) ;
printf ("Digite seu peso :") ;
scanf ("%f", &peso) ;
if ( idade > 50)
cont50++ ;
if((idade>=10) && (idade <=20))
md +=altura/2 ;
if(peso <40)
espantalho++ ;
mdpeso = (espantalho/2) *100 ;
}
printf ("\nO total de pessoas com idade superior a 50 e %d", cont50) ;
printf ("\nA media das alturas de pessoas com idade entre 10 e 20 anos e %.1f", md) ;
printf ("\nA porcentagem de pessoas com peso inferior a 40 kg e %f porcento", mdpeso) ;
return 0;
}
Did any of the answers solve your problem? Do you think you can accept one of them? If you haven’t already, see [tour] how to do this. You would help the community by identifying the best solution for you. You can only accept one of them, but you can vote for any question or answer you find useful on the entire site (when you have enough score).
– Maniero