Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Contributor: adminWhat is the output of following code
#1
What will be output of this c program and give reason
1.
Code:
int main(){
    
    printf("%d\n",sizeof('P'));
    return 0;
}


2.
Code:
int main(){
    char ch = 'P';
    printf("%d\n",sizeof(ch));
    return 0;
}
[-] The following 1 user says Thank You to admin for this post:
  • Ravishankar Chavare
Reply
#2
1.4 byte
Reason:every undefined value treated as integer so the final answer is 4


2.1 byte
Reason :ch variable defined as character so chacater size is 1byte
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)