Why this statement is legal C statement?? int apple = ā€˜cā€™ ; | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Why this statement is legal C statement?? int apple = ā€˜cā€™ ;

Why this statement is legal C statement?? int apple = ā€˜cā€™ ; Isn't int for numbers??

22nd Mar 2021, 7:27 AM
STOP
STOP - avatar
2 Respostas
+ 1
its legal because C reads every character as an integer. for instance, test this: int apple = 'a'; printf("int: %d\nchar: %d",apple,apple); // will print 97 a because to C, the character 'a' and the number 97 are the same thing.
22nd Mar 2021, 7:58 AM
Slick
Slick - avatar
+ 1
Integer for any known character is its ASCII value in most programming language. Refer this: http://www.asciitable.com/
22nd Mar 2021, 9:16 AM
Arun Bhattacharya
Arun Bhattacharya - avatar