0
i entered letter "g" instead of integer value for a & b for fun, but code "a+b" gave me value "8", why? lang-C.
#include <stdio.h> int main() { int a, b; printf("Enter two numbers:"); scanf("%d %d", &a, &b); printf("\nSum: %d", a+b); return 0; }
4 Réponses
+ 3
in C each character has its how integer representation, or let me just say character data is just like integer data type, you only convert to Ascii, just as Anhjje 🐑 have represented it for you, because you use the integer specifier all input will be converted to integer automatically and then use in you program
+ 1
Each character has an ASCII and binary value.
For example
D = 068 or 01000100
E = 069 or 01000101
F = 070 or 01000110
G = 071 or 01000111
Maybe it has something to do with this? Show your code so we can check it out
0
Can you provide code which u tried?