transfering scan,print to cin,cout

how can I transfer this 2 codes into cin,cout instead of scan,print

Char X;
float w ,l ,b , h , r ;
const float pi = 3.14;
Scanf("%c",X)
if (X==R) {scanf("%f,%f" w,l)
printf("%f" (w*l)
}
if (X==T){scanf("%f,%f" b,h)
printf("%f" (0.5*b*h)
}
if (X==C) {scanf("%f" r)
printf("%f" pow(r,2)*pi)
}
else printf("please enter R || T || C")


///////////////////////////////////////////

Char X;
float w ,l ,b , h , r ;
const float pi = 3.14;
Scanf("%c",X)
Switch(X)
Case R: {scanf("%d,%d" w,l)
printf("%f" (w*l)
}
Case T: {scanf("%f,%f" b,h)
printf("%f" (0.5*b*h)
}
Case C: {scanf("%f" r)
printf("%f" pow(r,2)*pi)
}
else printf("please enter R || T || C")

Last edited on
Have a look at this tutorial: http://www.cplusplus.com/doc/tutorial/basic_io/
Topic archived. No new replies allowed.