char datatype inside int main() function | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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

24th Feb 2020, 10:39 AM
Reiner
Reiner - avatar
2 Respostas
+ 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
24th Feb 2020, 10:52 AM
Arsenic
Arsenic - avatar
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
24th Feb 2020, 1:41 PM
Aryaman Mishra šŸ‡®šŸ‡³
Aryaman Mishra šŸ‡®šŸ‡³ - avatar