| Other C Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| What will be the result of the following program?
main()
{
char p[]="String";
int x=0;
if(p=="String")
{
printf("Pass 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
else
{
printf("Fail 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
}
a) Pass 1, Pass 2
b) Fail 1, Fail 2
c) Pass 1, Fail 2
d) Fail 1, Pass 2
e) syntax error during compilation
| IBM | 10 |
| which one is not preprocessor directive
a)#if b)#elif c)#undef d)#pragma
| Wipro | 13 |
| difference between i++* and *++i | IBM | 3 |
| #define min((a),(b)) ((a)<(b))?(a):(b)
main()
{
int i=0,a[20],*ptr;
ptr=a;
while(min(ptr++,&a[9])<&a[8]) i=i+1;
printf("i=%d\n",i);}
| | 3 |
| write a programme that inputs a number by user and gives
its multiplication table. | | 2 |
| without using arithmatic operator convert an intger variable
x into x+1 | | 1 |
| Write a program to write a given string in maximum
possibilities?
i.e str[5]="reddy";
i.e we can write this string in 120 ways
for that write a program | Subex | 3 |
| Struct(s)
{
int a;
long b;
}
Union (u)
{int a;
long b;
}
Print sizeof(s)and sizeof(u) if sizeof(int)=4 and
sizeof(long)=4
| Mascot | 2 |
| 2.main
{
int x,j,k;
j=k=6;x=2;
x=j*k;
printf("%d", x);
| HCL | 6 |
| print the following using nested for loop.
5 4 3 2 1
1 2 3 4
3 2 1
1 2
1
2 1
1 2 3
4 3 2 1
1 2 3 4 5 | | 5 |
| char ch="{'H','I',0};printf("%s",ch);what is output | Accenture | 9 |
| HOW TO ANSWER IF ASKED " WHAT KIND OF A PERSON ARE YOU?" I
NEED AN ANSWER THAT IMPRESS THE INTERVIEWER | | 2 |
| marge linklist | HCL | 1 |
| Function to find the given number is a power of 2 or not? | Motorola | 12 |
| how to implement stack operation using singly linked list | | 1 |
| suppose we use switch statement and we intilize years name
using enum statement like(jan,feb,mar,------dec) we take
integer value as an input .question is that the month which
we analyz is from 0 to 11 bt if i enter 12 than how he
again starts from begning and print jan | | 1 |
| what is the output of the following program?
#include<stdio.h>
void main()
{
float x=1.1;
while(x==1.1)
{
printf("\n%f",x);
x=x-0.1;
}
} | | 4 |
| main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
what is the output?
| Ramco | 4 |
| how to copy a string without using c function | | 5 |
| How to reverse a string using a recursive function, without
swapping or using an extra memory? | Motorola | 18 |
| |
| For more C Interview Questions Click Here |