0% found this document useful (0 votes)
25 views

C Interview Questions

The document contains several C code snippets and asks what the output would be for each. It includes examples of variable scoping, static variables, bitwise operators, and different loop constructs like for, while, and do-while loops.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

C Interview Questions

The document contains several C code snippets and asks what the output would be for each. It includes examples of variable scoping, static variables, bitwise operators, and different loop constructs like for, while, and do-while loops.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1. What will be the output of following program ?

#include

<stdio.h>
int main()
{
int var=100;
{
int var=200;
printf("%d...",var);
}
printf("%d",var);
return 0;
}

2. What will be the output of following program?

#include <stdio.h>
int fooo(void)
{
Static int num=0;
num++;
return num;
}
int main()
{
int val;
val=fooo();
printf("step1: %d\n",val);
val=fooo();
printf("step2: %d\n",val);
val=fooo();
printf("step3: %d\n",val);
return 0;
}
3. What will be the output of following program?
#include

<stdio.h>

int main()
{
int anyVar=10;
printf("%d",10);
return 0;
}

extern int anyVar;

4. What will be the output of following program ?

#include <stdio.h>
int main()
{
char var=0x04;

var = var | 0x04;


printf("%d,",var);
var |= 0x01;
printf("%d",var);
return 1;
}

What will be the output of following program ?

#include <stdio.h>
int main()
{
char flag=0;
flag |= (1<<1);
flag |= (1<<5);
printf("%0x",flag);
return 1;
}

What will be the output of following program ?


#include

<stdio.h>
int main()
{
char flag=0x0f;
flag &= ~0x02;
printf("%d",flag);
return 1;

What is the output of printf("%d")?

#inlude <stdio.h>
int main()
{
int i;
for(i=0;i<10;i++)
{
printf("%d ",i);
}
}

#inc lude <stdio.h>


int main()
{
int i=3;
while(i<10)
{
printf("%d\n",i);
i++;
}
}

#include <stdio.h>
int main()
{
int i=1;
do
{
printf("Value of i is %d\n",i);
i++;
}while(i<=4 && i>=2);
}

You might also like