+ 1
char datatype inside int main() function
#include <stdio.h> int main() { char n = 'X'; if (n == 'x' || n == 'X') printf("Roman numeral value 10.\n"); } here in this program we started with the main function which is "int main()" but we are declaring char datatypes which is irrelevant to int, is that right, if yes whats the diff b/w int main() void main and can we use any other like char main() and so on
3 Answers
+ 1
reiner A here "int" is return value of your main() function, which have nothing to do with type of variables inside the function.
Int main() simply means that main() function will return an integer value after the code inside it is executed.
Generally it returns 0 if the code ran without any errors
0
Data type written before main is actually its return type. It has no relation with the data types of the local variables declared inside a function. Just remember that if you use int, you have to add a return keyword too. But this is not the case with void