Problem: Read two floating points' values of double precision A and B, corresponding to two student's grades. After this, calculate the student's average, considering that grade A has weight 3.5 and B has weight 7.5. Each grade can be from zero to ten, always with one digit after the decimal point. Don’t forget to print the end of line after the result, otherwise you will receive “Presentation Error” . Don’t forget the space before and after the equal sign. Input The input file contains 2 floating points' values with one digit after the decimal point. Output Print MEDIA (average in Portuguese) according to the following example, with 5 digits after the decimal point and with a blank space before and after the equal signal. Solution: #include<stdio.h> int main() { double A,B,MEDIA; scanf("%lf",&A); scanf("%lf",&B); MEDIA=((A*3.5)+(B*7.5))/(3.5+7.5); printf("MEDIA = %0.5l...
Problem Read four numbers (N 1 , N 2 , N 3 , N 4 ), which one with 1 digit after the decimal point, corresponding to 4 scores obtained by a student. Calculate the average with weights 2, 3, 4 e 1 respectively, for these 4 scores and print the message "Media: " (Average), followed by the calculated result. If the average was 7.0 or more, print the message "Aluno aprovado." (Approved Student). If the average was less than 5.0, print the message: "Aluno reprovado." (Reproved Student). If the average was between 5.0 and 6.9, including these, the program must print the message "Aluno em exame." (In exam student). In case of exam, read one more score. Print the message "Nota do exame: " (Exam score) followed by the typed score. Recalculate the average (sum the exam score with the previous calculated average and divide by 2) and print the message “Aluno aprovado.” (Approved student) in...
Problem Read 3 floating-point numbers. After, print the roots of bhaskara’s formula. If it's impossible to calculate the roots because a division by zero or a square root of a negative number, presents the message “Impossivel calcular” . Input Read 3 floating-point numbers A, B and C. Output Print the result with 5 digits after the decimal point or the message if it is impossible to calculate. Solution #include<stdio.h> #include<math.h> int main() { double A,B,C,d,r1,r2; scanf("%lf%lf%lf",&A,&B,&C); d = B*B-4*A*C; if(A != 0 && d>=0) { d = sqrt(d); r1 = (d-B)/(2*A); r2 = (-d-B)/(2*A); printf("R1 = %0.5lf\nR2 = %0.5lf\n",r1,r2); } else printf("Impossivel calcular\n"); return 0; } Description: ...
Comments
Post a Comment