Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- float v1,v2,v3,v4,aux;
- printf("Insira quatro valores reais positivos: ");
- scanf("%f %f %f %f", &v1,&v2,&v3,&v4);
- if(v1<0 ){
- printf("Reinicie o programa e insira valores adequados! ");
- return 0;
- }
- else{
- if(v1<0||v2<0||v3<0||v4<0){
- printf("Reinicie o programa e insira valores adequados! ");
- return 0;
- }
- else{
- aux = (v1+(2*v2)+(3*v3)+(4*v4))/(1+2+3+4);
- printf("Os valores inseridos foram %.2f %.2f %.2f e %.2f. \n", v1,v2,v3,v4);
- printf("A media ponderada destes valores equivale a %.2f.", aux);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement