Please what is wrong with this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please what is wrong with this code?

I recently started studying c and I don't know why I am getting an error on this code .someone help please https://code.sololearn.com/cv05MebGEwQV/?ref=app

5th Jul 2022, 10:15 AM
steve Purpose
steve  Purpose - avatar
14 Answers
+ 1
William Owens you saw the corrected code..I wrote the code without the main(){}.Never knew it was mandatory.sites like w3schools didn't specify so.
5th Jul 2022, 2:19 PM
steve Purpose
steve  Purpose - avatar
+ 1
Most sites are not very specific about the published C standard to ease the learning process. Keep learning and hopefully the folks in the community will give you some tips along the way to get better and closer to standard. Hope to see see of your work soon.
6th Jul 2022, 2:14 AM
William Owens
William Owens - avatar
+ 1
steve Purpose w3 schools does specify. main() Line 3: Another thing that always appear in a C program, is main(). Every example up to this page displays it https://www.w3schools.com/c/c_syntax.php
6th Jul 2022, 7:06 PM
Chris Coder
Chris Coder - avatar
0
I thought it is a function on it's own.Do we use it with every variable declaration and operation
5th Jul 2022, 11:13 AM
steve Purpose
steve  Purpose - avatar
0
Ok..I've added it and it worked.But all the documentation from weschools and 1 or two others didn't say to always add main
5th Jul 2022, 11:16 AM
steve Purpose
steve  Purpose - avatar
0
Ok I see
5th Jul 2022, 11:16 AM
steve Purpose
steve  Purpose - avatar
0
Side note: it's a function, not method. Methods are object behaviour, while functions are stand-alone.
5th Jul 2022, 11:23 AM
Emerson Prado
Emerson Prado - avatar
0
Nothing is "wrong" with that code. I would however use main like int main(void){} and your output is going to be on the same line as your prompt think about adding a new line.
5th Jul 2022, 12:11 PM
William Owens
William Owens - avatar
0
Respek William Owens ✌️
6th Jul 2022, 8:12 AM
steve Purpose
steve  Purpose - avatar
0
William Owens you can view my few projects on my profile..My arcade coin counter app and my boxing round timer app..You can also follow my GitHub link on my profile to my GitHub .
6th Jul 2022, 11:26 AM
steve Purpose
steve  Purpose - avatar
0
Please write return 0; when u r using int data type
6th Jul 2022, 10:00 PM
chhanda naskar
chhanda naskar - avatar
6th Jul 2022, 10:18 PM
Abdullahi Usman
Abdullahi Usman - avatar
0
Thank you Chanda. It Can work with any non zero value actually.you can return 1 or 2
7th Jul 2022, 1:11 AM
steve Purpose
steve  Purpose - avatar
0
GarciaF1 what is this link?
7th Jul 2022, 9:17 AM
steve Purpose
steve  Purpose - avatar