can someone please figure out why this is not working? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

can someone please figure out why this is not working?

#include <stdio.h> int main() { int length, width, area; scanf("write the length and width of a rectangle:- %d %d", &length, &width); area = length * width; printf("the area of the rectangle is: %d \n", area); /* 50 */ return 0; }

29th Jul 2020, 10:56 AM
Pankaj Kumar Panda
Pankaj Kumar Panda - avatar
2 Answers
+ 4
The problem is you cannot print on scanf. scanf is for only taking input: Please see the code: https://code.sololearn.com/cXdODrEUzPiO/?ref=app
29th Jul 2020, 11:03 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 2
i made area a float and typecast float into the area equation. Also printf a %.2f https://code.sololearn.com/cC385zSpl2yI/?ref=app
29th Jul 2020, 11:02 AM
Slick
Slick - avatar