+ 2
What is integer value in c++
Int main() has int meaning integer, does this integer means only numbers?
10 Antworten
+ 5
NotHuman we are talking about C++ (standard) not ++C language of course at the end of day only binary code matters ..
+ 2
"int main()" means that function needs to return some integer at the end of the execution and we do so by returning 0 at the end of the program.
+ 1
Sanjana Sinha means that program executed successfully.
+ 1
ChillPill 🙃😌
0
Returning to zero means?
0
Sanjana Sinha return is a predefined keyword if u you about function than u can understood much better if you making any function rather than void it will return any values for example
int calculate () this calculate will return int value u need to use return statement or u u writing like this
float calculate ()
{
Return statement
}
But in case of
void calculate ()
{
No return
}
If u writting anything apart from void you need to return any value it can be int float char ..... anything.
In c language generally we using void main () as a main function but its removed in c98 as long year ago .And cpp is more strict than C so if u will use void main() as a main function in cpp it will give you warnings and error. when you using int main its necessary to use return keyword so we writting
return 0 which denotes your program is successfully executed return 1 for failure.
If u dont like to write return 0 then you can write like this
return EXIT_SUCCESS ;
same in case of failure
return EXIT_FAILURE;
0
ChillPill sir can you pls tell about this. string code{
R"(
#include <iostream>
int main(){
std::cout << "helloworld" << std::endl;
return 42;
}
)"
};
How its working becz i never studied this
- 1
Возвращает - байты :)
- 2
Martin Taylor (IYANR) C++ is language and its compilers are just some collection of files that can be modified. In addition to return type you can even rename main() function to nima() for example. If you want more you can give a new name to it like The ++C Language. If you have a country under your control universities will teach it instead of standart C++. Anyway text files are under our control even though we may not control countries. But in general you are right
- 4
yes it means that method can return only integer numbers. if you don't like you can change it to void, pointer .. it is free and under your control