hello everyone, i've got a quick questions to ask. assuming
a = 1, b = 2, c = 3, d = 4
if d='4' is it true is d='4' and d=4 the same? without ''?
and if !(d = 3) is this false? i know ! means no but not quite sure. thanks
can take some time to look at ascii charts
the char '4' is integer value 52.
added a char equal to '0' and an integer equal to number 4.
outcome was number 4 which is integer/decimal value 52.
tested to see result
probably better to add integers to integers and chars to chars.
if you add 48 + 52, you get 100 decimal. same as char 'd'.
1 2 3 4 5 6 7 8 9 10 11 12
#include <stdio.h>
int main()
{
int a = 48; // char '0' in decimal form
int b = 52; // char '4' in decimal form
printf("a is 48, b is 52, the addition of both integers is char %c, integer %d\n\n", a+b, a+b);
return 0;
}
#include <stdio.h>
int main()
{
char a = 15;
char b = 9;
printf("char a value is 15, char b value is 9\n\n");
printf("char a decimal value is %d, char b decimal value is %d\n\n", a, b);
printf("the addition of both chars is char %c, integer %d\n\n", a+b, a+b);
return 0;
}
char'0' is 48 decimal
char'1' is 49 decimal
char'2' is 50 decimal
char'3' is 51 decimal
char'4' is 52 decimal
char'5' is 53 decimal
char'6' is 54 decimal
char'7' is 55 decimal
char'8' is 56 decimal
char'9' is 57 decimal
NULL char is 0 decimal
Start of heading (SOH) is 1 decimal
Start of text (STX) is 2 decimal
End of text (ETX) is 3 decimal
End of transmissions (EOT) is 4 decimal
Enquiry (ENQ) is 5 decimal
Acknowledge (ACK) is 6 decimal
Bell (BEL) is 7 decimal
Backspace (BS) is 8 decimal
Horizontal tab (TAB) is 9 decimal
0 to 9's to watch out for