Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.


Please wait...

C Programming :: Declarations and Initializations

41. #include
void main()
{
unsigned short a=-1;
unsigned char b=a;
printf("%d %d ",a,b);
}
What is output of the program?

Answer: Option C

Explanation:

The value range for unsigned short  is from 0 to 65,535.

Clearly, a cannot be assigned with -1, as -1 is not in the range of unsigned short. So, when we try to assign -1 to a, automatically 65535 gets assigned to a, as it follows a cyclic pattern.

Same is the result when we try to assign -1 to b, which is an unsigned char. The value range for unsigned char is from 0 to 255. So, automatically, 255 gets assigned to b.

Hence, the output is 65535 255.

Workspace


Tags:  Cisco

42. What will be the result of the following program?

#include
int main()
{
static int i;
int j;
for(j=0;j<10;j++)
{
i= i+2;
i = i-j;
}
printf("%d",i);
return 0;
}

Answer: Option B

Explanation:

can anyone help with this????


Workspace


Tags:  TCS

43. What will be output of following c program?

#include
long unsigned static const ddlg(){
static const long unsigned a=0101;
return a;
}
int main(){
long number;
number=ddlg();
printf("%X",number);
return 0;
}

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace


Tags:  TCS

Answer: Option D

Explanation:

Option B is also correct. Type it out @ideone.com and check yourself.

Workspace


Tags:  No Tags on this question yet!

45. printd (int n)
{
if (n < 0)
{
printf ("-");
n = -n;
}
if (n % 10)
printf ("%d", n);
else
printf ("%d", n/10);
printf ("%d", n);
}

If initially n = -24;

Answer: Option C

Explanation:

Let us discuss the code line by line-

Initially, n=24

Line 3 =>    if(n<0), is true because -24<0.

Line 5 =>    "-" get printed.

Line 6 =>    n=-n, or n=-(-24), or n=24

Line 8 =>    if(n%10), or if(24%10), or if(4), which is true as "4 is not equal to 0" is true.

Line 9 =>    "24" gets printed

Here, the else block won't get executed as if block has already executed.

Finally, Line 12 =>    "24" gets printed.

Hence, the complete output is -2424

Workspace


Tags:  No Tags on this question yet!

46. What is the output of the following 'C' program ?

#include
int main()
{
int i = 10 ;
printf("%d\n", i/2 );

}

Answer: Option B

Explanation:

Clearly, value of i=10, and we are printing value of 'i/2'.

Hence, the output is 5.

Workspace


Tags:  Global Edge

47. What is the output of the following 'C' program ?

#include
int main()
{
char c = 255;
printf ("%d",c);
return 0;
}

Answer: Option B

Explanation:

255 in binary can be represented as 11111111. What does this number represent?

Before that, we should know that char can store numbers only -128 to 127. The most significant bit is kept for the sign bit. Clearly, 11111111 represents a negative number. To check which number it represents we find the 2’s complement of it, which is 00000001, which is nothing but 1 in decimal.

Hence, 11111111 represents -1, which is the required output.

 

Workspace


Tags:  Global Edge

48. What will be output of the following "C" code?

#include
main()
{
100;
printf("%d",100);
}

Answer: Option B

Explanation:

Here, the only thing that's getting executed is line no. 5, so 100 gets executed.

Line no. 4 is basically of no is use. You may write any number you want, but it's practically of no use, it's still going to print 100.

Workspace


Tags:  TCS

49. Predict the output of following code:

void main()
{
float a=1.1;
double b=1.1;
if(a==b)
printf("equal");
else
printf("not equal");
}

Answer: Option B

Explanation:

datatype is different cant be compared; hence result will be 0

Workspace


Tags:  TCS

50. Predict the output of following code:

#include
void main()
{
int sum;
char ch1='a';
char ch2='b';sum=ch1+ch2;
printf("%d",sum);
}

Answer: Option B

Explanation:

ascii sum;
sum = 97+98 = 195

Workspace


Tags:  TCS



Most Popular Qs.

Latest MCQ Qs.