Can you explain the C language program?
MY PARTNER AND I took it from your friend, the question is to print this ASCII value and their own characters, but how should a char input (%c) consuming i (since it truly is an integer)
#include
#include
main()
clrscr();
int i=0, c=255;
while(i<=c)
printf(“%d=%c\t”, when i, i);
i++;
getch();
integer types (including char, which is usually a one byte integer) can translate concerning each other
the sole problem is definitely if a good integer form is translated that will another variety that can’t contain the first one
for instance, int d = 257;
char c2 = d;
c2 would likely wrap that will -125
(it will not wrap in order to 2 since they’re not unsigned integers – they may be signed, put simply half with their value visits negative, 50 percent to positive)
throughout printf, this conversion is completed automatically
but you might be right – for being “politically correct” he needs declared c being a unsigned char
ps, into the other poster, no it might not be infinite, because he wouldn’t declare any with the variables being a char
Its fairly simple.When your current program posters %d (Integer) it might automatically impress the integer
shifting i
Although when your current program posters %c, it posters the character who has ‘i’ as being the ASCII Value
For instance, when i becomes 97, it might print
97 = some sort of (Because 97 will be the ASCII value for that letter ‘a’)
Hence
.
.
.
97 = a
98 = b
99 = c
.
.
.
The reason being the ASCII Value for the is 97
Direct the ascii table here
http://www.asciitable.com/
The ASCII stand will contain all of the ascii values for that printable characters
Your program cannot go in to infinity loop
Hope this particular helps
when you have %c it is going to try to print integer for a character plus the only strategy to do so is to convert the item from ascii code towards the character in addition to print that character
yeah it might not be infinite.
Leave a Reply
You must be logged in to post a comment.