Is anything wrong here | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is anything wrong here

#include<stdio.h> #include<math.h> void main() { int t,h; float c; printf("enter c,t,h"); scanf("%d %d %f",&c,&t,&h); if(((h>50)&&(c>.7)&&(t<5600))||((h<50)&&(c<.7)&&(t<5600))||((h<50)&&(c>.7)&&(t>5600))) printf("grade6"); else printf("poor steel"); #include<stdio.h> #include<math.h> void main() { int t,h; float c; printf("enter c,t,h"); scanf("%d %d %f",&c,&t,&h); if(((h>50)&&(c>.7)&&(t<5600))||((h<50)&&(c<.7)&&(t<5600))||((h<50)&&(c>.7)&&(t>5600))) printf("grade6"); else printf("poor steel"); } }

1st Jul 2018, 5:27 PM
Dipu Ojha
Dipu Ojha - avatar
8 Answers
+ 4
Hi Iulian Gudumac Dipu Ojha knows this already as in the previous post please read posts before commenting
1st Jul 2018, 6:12 PM
Agent
Agent - avatar
+ 3
Yes, the code is repeated and sorry i dont fully understand C
1st Jul 2018, 6:03 PM
Agent
Agent - avatar
+ 1
You inserted code twice and made error in scanf. Here is the corrected version. #include<stdio.h> #include<math.h> void main() { int t,h; float c; printf("enter c,t,h"); /* Error was here scanf("%d %d %f",&c,&t,&h); */ scanf("%f %d %d",&c,&t,&h); if(((h>50)&&(c>0.7)&&(t<5600))||((h<50)&&(c<0.7)&&(t<5600))||((h<50)&&(c>0.7)&&(t>5600))) printf("grade6"); else printf("poor steel"); }
1st Jul 2018, 6:10 PM
Iulian Gudumac
Iulian Gudumac - avatar
+ 1
There was also an error in scanf() The first variable read is of float type so use %f for var c. The remaining two variables are of int type, so use %d for vars t, h.
1st Jul 2018, 6:18 PM
Iulian Gudumac
Iulian Gudumac - avatar
+ 1
I don't C ;)
1st Jul 2018, 6:29 PM
grzesiekmq
grzesiekmq - avatar
+ 1
Pay attention to the variable types inside the scanf. You tried to read a float variable c using %d. Should be used %f for float varible c. For the int variables t,h should be used %d%d. as result, %d %d %f will read int int float I hope this helps.
1st Jul 2018, 7:00 PM
Iulian Gudumac
Iulian Gudumac - avatar
+ 1
thanks
1st Jul 2018, 9:13 PM
Dipu Ojha
Dipu Ojha - avatar
0
oo only that nothing in the coding stuff
1st Jul 2018, 6:06 PM
Dipu Ojha
Dipu Ojha - avatar