Why my code is not working in c? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why my code is not working in c?

#include<stdio.h> int main(){ int length =4, breadth=5; int area=length × breadth; printf("%d", area); return 0; }

12th Oct 2023, 11:49 AM
virendra singh
virendra singh - avatar
5 Answers
+ 7
The correct symbol for multiplication is *
12th Oct 2023, 11:57 AM
Tibor Santa
Tibor Santa - avatar
+ 5
int area = length * breadth; ...and also, instead of using breadth, it's more common to use width.
12th Oct 2023, 12:02 PM
Jan
Jan - avatar
+ 2
use '*' rather than using '×' , cuz in programming we define multiply with '*' not '×'
12th Oct 2023, 2:17 PM
Alhaaz
Alhaaz - avatar
+ 2
The issue in your code is with the multiplication operator. In C, you should use '*' for multiplication, not '×' (which is a different Unicode character). Here is the corrected version of your code: #include <stdio.h> int main() { int length = 4, breadth = 5; int area = length * breadth; printf("%d", area); return 0; } This code will work correctly and print 20 which is the result of 'length * breadth'.
13th Oct 2023, 12:56 AM
Lutreze Hue Jacinto
Lutreze Hue Jacinto - avatar
0
Ahahahaha, that is a easy one. It should be * not x. xD
13th Oct 2023, 8:40 PM
Werg Serium
Werg Serium - avatar