C Interview Questions
C Interview Questions
C Interview Questions
void main()
{
int i;
i=2;
pskills:
printf("%d",i);
i=i+2;
if(i<=20)
gotopskills;
}
(A) 3 5 7 9 ....... 21 23
(B) 2 4 6 8 ....... 20
(C) 3 5 7 9 ....... 21
(D) 2 4 6 8 ....... 20 22
Ques 2 : What will be the output of the following program?
main()
{
printf(3+"Proskills"+4);
}
(A) Compilation Error
(B) skills
(C) kills
(D) ls
Ques 3 : What will be the output of the following program?
main()
{
printf("%c","Pskills"[4]);
}
(A) Compilation Error
(B) P
(C) i
(D) l
Ques 4 : What value of c will get printed
main()
{
int a, b, c;
a = 10;
b = 20;
c = printf("%d",a) + ++b;
printf ("%d",c);
}
(A) 23
(B) 22
(C) 30
(D) Compilation Error
Ques 5 : What will be the output
main()
{
int i;
i = 10;
printf("%d\t",5,6);
printf("%d", i , i++);
}
(A) 5 11
(B) 6 10
(C) 6 11
(D) 5 10
Ques 6 : What the below statement will print if a=10 and b = 20?
printf("%d",a==b);
(A) 20
(B) 10
(C) 1
(D) 0
Ques 7 : How many times the below loop will get executed?
main()
{
int i,j;
i = 10;
for (j=i==10 ; j<=10 ; j++)
{
printf("\n%d",j);
}
}
(A) 1
(B) 10
(C) 11
(D) Compilation Error
Ques 8 : How many times the while loop will get executed?
main ( )
{
int a = 1 ;
while ( a<= 100) ;
{
printf( "%d", a++ ) ;
}
}
(A) 100
(B) 1
(C) 0
(D) Infinite
Ques 9 : What will be the output
main()
{
char *ptr = "Pskills.org";
char a =
printf("%c", ++*ptr++);
}
(A) Compilation Error
(B) Q
(C) P
(D) a
Ques 10 : What are storage classes in 'C' language? choose multiple-
a. auto keyword
b. static keyword
c. register keyword
d. extern keyword
e. automatic
f. static
(A) a,b,c
(B) a,b,c,d
(C) e,f
(D) none of these
Ques 11 : Hofdw many storage class specifiers in "C" language?
(A) 3
(B) 4
(C) 5
(D) 6
Ques 12 : How many variables scopes are there in "C" language?
(A) 2
(B) 3
(C) 4
(D) 5
Ques 13 : What is the output of the following code?
#include "stdio.h"
main()
{
int i;
for(i=0;i<5;i++)
{
static int a=0;
int b=0;
a++;
b++;
printf("%d %d",a,b);
}
return 0;
}
(A) 1 1 2 1 3 1 4 1 4 1
(B) 1 1 2 1 3 1 4 1 5 1
(C) 1 0 2 0 3 1 4 1 5 1
(D) 0 1 2 0 3 1 4 1 5 1
Ques 14 : What is the output of the following code?
#include "stdio.h"
main(){
static int s;
++s;
printf("%d",s);
if(s<=3)
main();
printf("%d",s);
return 0;
}
(A) 1 2 3 4 4 4 4 4
(B) 0 1 2 3 4 4 4 4
(C) 1 2 3 3 4 4 4 4
(D) 0 1 3 4 4 4 4 4
Ques 15 : What is the output of the following code?
#include "stdio.h"
extern int a;
main(){
printf("\na=%d",a);
return 0;
}
(A) a=0
(B) a=garbage value
(C) error
(D) none of these
Ques 16 : What is the output of the following code?
#include "stdio.h"
int a;
main(){
printf("\n a= %d",a);
return 0;
}
(A) a=0
(B) a=garbage value
(C) error
(D) none of these
Ques 17 : What is the output of the following code?
#include "stdio.h"
extern int a;
main(){
printf("\n a=%d",a);
return 0;
}
int a;
(A) a=0
(B) error
(C) nothing display on screen
(D) none of these
Ques 18 : What is the output of the following code?
#include "stdio.h"
extern int a;
main(){
printf("\n a=%d",a);
return 0;
}
int a=5;
(A) a=0
(B) a=5
(C) a=garbage value
(D) error
Ques 19 : What is the output of the following code?
#include "stdio.h"
extern int a=5;
main(){
void fun();
printf("\n a=%d",a);
fun();
return 0;
}
int a;
void fun(){
printf("\n in fun a=%d",a);
}
(A) a=0 in fun a=5
(B) a=5 in fun a=0
(C) a=5 in fun a=5
(D) error
Ques 20 : What is the output of the following code?
#include "stdio.h"
extern int a;
main(){
void fun();
printf("\n a=%d",a);
fun();
return 0;
}
int a=7;
void fun(){
printf("\n in fun a=%d",a);
}
(A) a=0 in fun a=0
(B) a=7 in fun a=7
(C) a=7 in fun a=0
(D) error
Programs:
QA 1)
Input Format
The first line contains a single integer , denoting the number of boxes.
lines follow with three integers on each separated by single spaces , and which are length, width and
Constraint
1>= n <=100
1>= length,width,height<=100
Output Format
For every box from the input which has a height lesser than feet, print its volume in a separate line.
Sample Input 0
4
555
1 2 40
10 5 41
7 2 42
Sample Output 0
125
80
Explanation 0
The first box is really low, only feet tall, so it can pass through the tunnel and its volume is .
The second box is sufficiently low, its volume is .
The third box is exactly feet tall, so it cannot pass. The same can be said about the fourth box.
QA 2)
A string is said to be a child of a another string if it can be formed by deleting 0 or more characters from
the other string. Given two strings of equal length, what's the longest string that can be constructed such
For example, ABCD and ABDC have two children with maximum length 3, ABC and ABD. They can be
formed by eliminating either the D or C from both strings. Note that we will not consider ABCD as a
Function Description
Complete the commonChild function in the editor below. It should return the longest string which is a
Input Format
Constraints
Output Format
Print the length of the longest string , such that is a child of both and .
Sample Input
HARRY
SALLY
Sample Output
2
Explanation
The longest string that can be formed by deleting zero or more characters fromHARRY
AndSALLY is AY , whose length is 2.