DIR Return Create A Forum - Home
---------------------------------------------------------
techsuns
HTML https://techsuns.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: OutPut of a Program
*****************************************************
#Post#: 481--------------------------------------------------
What is the ouput of both the programs?
DIR By: kranthipls
Date: March 26, 2013, 10:59 am
---------------------------------------------------------
--- Code ---
#include <stdio.h>
int main()
{
int i = 5, j = 10, k = 15;
//Assume 32 bit architecture
printf("%d ", sizeof(k /= i + j));
printf("%d", k);
return 0;
}
--- End Code ---
--- Code ---
#include <stdio.h>
int main()
{
//Assume sizeof character is 1 byte and sizeof integer is
4 bytes
printf("%d", sizeof(printf("GeeksQuiz")));
return 0;
}
--- End Code ---
#Post#: 482--------------------------------------------------
Re: What is the ouput of both the programs?
DIR By: kranthipls
Date: March 28, 2013, 12:44 am
---------------------------------------------------------
Please execute it and see. The answer may not be what you are
expecting.
#Post#: 483--------------------------------------------------
Re: What is the ouput of both the programs?
DIR By: adi
Date: March 28, 2013, 4:04 am
---------------------------------------------------------
1. since we do integer division the output of first is an
integer ie k /= i + j is an integer and so sizeof int gives 4.
and k =15
[/size]
[/size]
[/size]2. printf returns integer so again sizeof gives 4
*****************************************************
Page 1 of 1