edited by
859 views

2 Answers

Best answer
2 votes
2 votes
It is sort of machine dependent. Though, if you assume size of char as 8 byte, the reason behind the output as

@

is overflow in binary addition.

'A' has ASCII value of 65. In binary is 0100 0001

and 255 in binary is 1111 1111

If you add both of them, you will get 1 0100 0000 which indicates overflow.

Considering that the size of char is only 1 byte, now c will contain 0100 0000 which is 64.

If you look up in ASCII table, 64 represents @
selected by
1 votes
1 votes
Output for this code is '@'

Since here c=A+255;

Add operator sum the ASCII code for A and 255 and print the character specified by that ASCII code

ASCII code for A is 65.So after sum it will being 320.

Since there are 128 ASCII code from 0 to 127 are assigned.

from 320 , 256 will be first ASCII Character according to number system rule

Now 320-256=64

So in output Character which have ASCII code 64 assigned is printed in output.

so output is 64.

Related questions

0 votes
0 votes
2 answers
1
shiva0 asked Jul 18, 2018
4,491 views
#include <stdio.h>main(){char *p = 0;*p = 'a';printf("value in pointer p is %c\n", *p);}
1 votes
1 votes
2 answers
2
sushmita asked Sep 28, 2018
442 views
void main() { char*s[]={"iceland","Greenland","Ireland","Switzerland"}; char ptr[]={s+3,s+2,s+1,s}; char *p=ptr; printf(\%s ", ++p); printf(\%s ",*(*++p+3); printf(\%s ...
2 votes
2 votes
2 answers
4
atulcse asked Jan 15, 2022
688 views
Consider the following programint find (int n) { int a = 1; for (i = 1; i < = n; i ++) for (j = 1; j < = i; j++) for (k = 1; k <= j, k++) a = a + 1; ...