TCS - D2-S2
TCS - D2-S2
- Ninja
Sub-Topic (Example: name of college)
MCQs
Question 1
What argv[0] and argv[1] denote in Command line Arguments ?
Ans: B
Question 2
Choose the correct statement :- while (0 == 0) { }
A Number of Arguments
)
B Number of Arguments - 1
)
C Number of Arguments + 2
)
D Number of Arguments + 1
)
Question 3
Which one of these is equivalent to argc ?
A Number of Arguments
)
B Number of Arguments - 1
)
C Number of Arguments + 2
)
D Number of Arguments + 1
)
Ans: D
Question 4
What is dangling pointer?
A) int
B) float
C) char
D) string
Question 5
Which of the following is not a data type in C?
A) int
B) float
C) char
D) string
Ans: D
Question 6
what is the purpose of ftell ?
Ans: A
Question 7
What is the similarity between enum, union and structure?
Ans: B
Question 8
A memory leak happens when?
Ans: A
Question 9
Which of the following statement is true about the c language?
Ans: A
Question 10
While declaring parameters for main, the second parameter argv
should be declared as
A) char argv
B) char argv[]
C) char *argv[]
D) char **argv
Question 10
While declaring parameters for main, the second parameter argv
should be declared as
A) char argv
B) char argv[]
C) char *argv[]
D) char **argv
Ans: D
Question 11
Predict the output:
#include<stdio.h>
int main()
{
clrscr();
int x = 10;
printf("%d", x);
return 0
}
#include<stdio.h>
int main()
{
clrscr();
int x = 10;
printf("%d", x);
return 0
}
A break
)
B continue
)
C goto
)
D return
)
Question 12
Which of this is used to skip one iteration?
A break
)
B continue
)
C goto
)
D return
)
Ans: B
Question 13
which of the following is not a fundamental data type?
A Enum
)
B unsigned long int
)
C Long int
)
D double
)
Question 13
which of the following is not a fundamental data type?
A Enum
)
B unsigned long int
)
C Long int
)
D double
)
Ans: A
Question 14
What is the similarity between enum and struct ?
A looping
)
B a function calls another function repeatedly
)
C a function calls repeatedly
)
D function calls itself repeatedly
)
Question 15
What is recursion ?
A looping
)
B a function calls another function repeatedly
)
C a function calls repeatedly
)
D function calls itself repeatedly
)
Ans: D
Question 16
Where did local variable get stored ?
A Disk
)
B Stack
)
C Heap
)
D Register
)
Question 16
Where did local variable get stored ?
A Disk
)
B Stack
)
C Heap
)
D Register
)
Ans: B
Question 17
Which of the following is a User-defined data type?
A friend
)
B true
)
C volatile
)
D export
)
Question 18
Which of the following cannot be a variable name in C?
A friend
)
B true
)
C volatile
)
D export
)
Ans: C
Question 19
Which keyword can be used for coming out of recursion?
A break
)
B return
)
C exit
)
D Both break and return
)
Question 19
Which keyword can be used for coming out of recursion?
A break
)
B return
)
C exit
)
D Both break and return
)
Ans: B
Question 20
What will be output of the following program if argument passed to
command lines are : prog 1 4 2.
#include<stdio.h>
int main(int argc, char *argv[])
{
while(argc--)
printf("%s\n",argv[argc]);
return 0;
}
A 241
)
B Garbage-value 2 4 1
)
C Garbage-value 2 4 1 prog
)
D Infinte Loop
)
A 241
)
B Garbage-value 2 4 1
)
C Garbage-value 2 4 1 prog
)
D Infinte Loop
)
Ans: A
Question 21
int **ptr; is
A) pointer to pointer
B) pointer to integer
C) Invalid
D) None of the above
Question 21
int **ptr; is
A) pointer to pointer
B) pointer to integer
C) Invalid
D) None of the above
Ans: A
Question 22
What argv means in command line argument?
A Array of pointers
)
B pointer to a character array
)
C Array of character pointers
)
D Array of Strings
)
Question 22
What argv means in command line argument?
A Array of pointers
)
B pointer to a character array
)
C Array of character pointers
)
D Array of Strings
)
Ans: C
Question 23
What is the first argument of command line ?
A File Name
)
B Program Designation
)
C argument passed by user
)
D Program
)
Question 23
What is the first argument of command line ?
A File Name
)
B Program Designation
)
C argument passed by user
)
D Program
)
Ans: A
Question 24
What does argc and argv indicate in int main(int argc, char
*argv[]) ?
#include <stdio.h>
int main()
{
float x = 'a';
printf("%f", x);
return 0;
}
A 97.000000
)
C a.0000000
)
D a
)
A 97.000000
)
C a.0000000
)
D a
)
Ans: A
Question 26
What is the size of an int data type?
A 4 Bytes
)
B 8 Bytes
)
C Depends on the system/compiler
)
D Cannot be determined
)
Question 26
What is the size of an int data type?
A 4 Bytes
)
B 8 Bytes
)
C Depends on the system/compiler
)
D Cannot be determined
)
Ans: C
Question 27
Predict the output:
#include <stdio.h>
int main()
{
if(1)
printf("hai");
else
printf("hello");
return 0;
}
#include <stdio.h>
int main()
{
if(1)
printf("hai");
else
printf("hello");
return 0;
}
#include<stdio.h>
int main()
{
if(5,4,3,2,1,0)
printf("True");
else
printf("False");
return 0;
}
#include<stdio.h>
int main()
{
if(5,4,3,2,1,0)
printf("True");
else
printf("False");
return 0;
}
#include<stdio.h>
int main()
{
if(printf("Hai"))
printf("Face");
else
printf("Focus");
return 0;
}
#include<stdio.h>
int main()
{
if(printf("Hai"))
printf("Face");
else
printf("Focus");
return 0;
}
#include<stdio.h>
int main()
{
if(-1)
printf("True");
else
printf("False");
return 0;
}
#include<stdio.h>
int main()
{
if(-1)
printf("True");
else
printf("False");
return 0;
}
#include<stdio.h>
int main()
{
int a = 100, b = 300;
if(a > 50)
a = 200;
b = 400;
printf("%d", b);
return 0;
}
#include<stdio.h>
int main()
{
int a = 100, b = 300;
if(a > 50)
a = 200;
b = 400;
printf("%d", b);
return 0;
}
#include<stdio.h>
int main()
{
int a = 2;
if(a-- , --a, a)
printf("Tom");
else
printf("Jerry");
return 0;
}
#include<stdio.h>
int main()
{
int a = 2;
if(a-- , --a, a)
printf("Tom");
else
printf("Jerry");
return 0;
}
#include<stdio.h>
int main()
{
printf("%d", sizeof('a'));
return 0;
}
#include<stdio.h>
int main()
{
printf("%d", sizeof('a'));
return 0;
}
#include<stdio.h>
int main()
{
int a = b = c = d = 10;
printf("%d,%d,%d,%d", a, b, c, d);
}
#include<stdio.h>
int main()
{
int a = b = c = d = 10;
printf("%d,%d,%d,%d", a, b, c, d);
}
#include<stdio.h>
int main()
{
int sum;
char ch1 = 'a';
char ch2 = 'b';
sum = ch1 + ch2;
printf("%d", sum);
return 0;
}
#include<stdio.h>
int main()
{
int sum;
char ch1 = 'a';
char ch2 = 'b';
sum = ch1 + ch2;
printf("%d", sum);
return 0;
}
#include<stdio.h>
int main()
{
float a = 1.1; double b = 1.1;
if(a == b)
printf("equal");
else
printf("not equal");
return 0;
}
#include<stdio.h>
int main()
{
float a = 1.1; double b = 1.1;
if(a == b)
printf("equal");
else
printf("not equal");
return 0;
}
A) int
B) float
C) char
D) void
Question 39
What is the return type of printf() and scanf() function ?
A) int
B) float
C) char
D) void
Ans: A
Question 40
Predict the output:
#include<stdio.h>
int main()
{
printf("%%%%");
return 0;
}
#include<stdio.h>
int main()
{
printf("%%%%");
return 0;
}
#include<stdio.h>
int main()
{
printf("%d");
return 0;
}
A) 0 B) 1 C) Error D) Garbage
Value
Question 41
Predict the output:
#include<stdio.h>
int main()
{
printf("%d");
return 0;
}
A) 0 B) 1 C) Error D) Garbage
Ans: D Value
Question 42
Predict the output:
#include<stdio.h>
int main()
{
100;
printf("%d“, 100);
return 0;
}
#include<stdio.h>
int main()
{
100;
printf("%d“, 100);
return 0;
}
Ans: B Value
Question 43
Predict the output:
#include<stdio.h>
int main()
{
printf("%d", printf("FACE"));
return 0;
}
#include<stdio.h>
int main()
{
printf("%d", printf("FACE"));
return 0;
}
#include<stdio.h>
int main()
{
printf("FACE"+2);
return 0;
}
A) FACE B) FA C) CE D) Garbage
Value
Question 44
Predict the output:
#include<stdio.h>
int main()
{
printf("FACE"+2);
return 0;
}
A) FACE B) FA C) CE D) Garbage
Ans: C Value
Question 45
Predict the output:
#include<stdio.h>
int main()
{
int a = 2000;
printf("%2d", a);
return 0;
}
#include<stdio.h>
int main()
{
int a = 2000;
printf("%2d", a);
return 0;
}
#include<stdio.h>
int main()
{
int x = 10, c, d, a;
d = !x + x;
c = x && x || printf("hai\t");
a = x && x && printf("hai\t");
printf("%d,%d,%d", d, c, a);
return 0;
}
#include<stdio.h>
int main()
{
int x = 10, c, d, a;
d = !x + x;
c = x && x || printf("hai\t");
a = x && x && printf("hai\t");
printf("%d,%d,%d", d, c, a);
return 0;
}
#include<stdio.h>
int main()
{
int x, a = 10;
x = a == 10 ? printf("hai\t") : printf("hello\n");
printf("%d", x);
return 0;
}
#include<stdio.h>
int main()
{
int x, a = 10;
x = a == 10 ? printf("hai\t") : printf("hello\n");
printf("%d", x);
return 0;
}
#include<stdio.h>
int main()
{
unsigned int x = 0xffff;
~x;
printf("%x", x);
return 0;
}
#include<stdio.h>
int main()
{
unsigned int x = 0xffff;
~x;
printf("%x", x);
return 0;
}
#include<stdio.h>
int main()
{
int a = 10, b = 20, c = 5, d;
d = a < b < c;
printf("%d", d);
return 0;
A) 0 B) 1 C) 5 D) Error
Question 49
Predict the output:
#include<stdio.h>
int main()
{
int a = 10, b = 20, c = 5, d;
d = a < b < c;
printf("%d", d);
return 0;
A) 0 B) 1 C) 5 D) Error
Ans: B
Question 50
Predict the output:
#include<stdio.h>
int main()
{
int x = 10, y = -10;
printf("%x\t", x << 2);
printf("%x", y >> 2);
return 0;
#include<stdio.h>
int main()
{
int x = 10, y = -10;
printf("%x\t", x << 2);
printf("%x", y >> 2);
return 0;
#include<stdio.h>
int main()
{
int a, x = 2, 3, 4, 5;
a=1, 2, 3, 4, 5;
printf("%d,%d", x, a);
return 0;
#include<stdio.h>
int main()
{
int a, x = 2, 3, 4, 5;
a=1, 2, 3, 4, 5;
printf("%d,%d", x, a);
return 0;
Ans: D
Question 52
Predict the output:
#include<stdio.h>
int main()
{
int a, x = (2, 3, 4, 5);
a = 1, 2, 3, 4, 5;
printf("%d,%d", x, a);
return 0;
#include<stdio.h>
int main()
{
int a, x = (2, 3, 4, 5);
a = 1, 2, 3, 4, 5;
printf("%d,%d", x, a);
return 0;
#include<stdio.h>
int main()
{
int i = 10, j = 2, k = 0, m;
m = ++i || ++j && ++k;
printf("%d,%d,%d,%d", i, j, k, m);
return 0;
#include<stdio.h>
int main()
{
int i = 10, j = 2, k = 0, m;
m = ++i || ++j && ++k;
printf("%d,%d,%d,%d", i, j, k, m);
return 0;
#include<stdio.h>
int main()
{
int i = 10, j = 2, k = 0, m;
m = ++i && ++j && ++k;
printf("%d,%d,%d,%d", i, j, k, m);
return 0;
#include<stdio.h>
int main()
{
int i = 10, j = 2, k = 0, m;
m = ++i && ++j && ++k;
printf("%d,%d,%d,%d", i, j, k, m);
return 0;
#include<stdio.h>
int main()
{
int x, a = 10;
x = 9 * 5 + 7 / 3 – 6 + a;
printf("%d", x);
return 0;
#include<stdio.h>
int main()
{
int x, a = 10;
x = 9 * 5 + 7 / 3 – 6 + a;
printf("%d", x);
return 0;
#include<stdio.h>
int main()
{ 0
int var = 20;
printf("%d", var);
{
int var = 30;
printf("%d", var);
}
return 0;
}
#include<stdio.h>
int main()
{ 0
int var = 20;
printf("%d", var);
{
int var = 30;
printf("%d", var);
}
return 0;
}
#include<stdio.h>
int main()
{
int i = -1;
-i;
printf("%d,%d", i, -1);
return 0;
#include<stdio.h>
int main()
{
int i = -1;
-i;
printf("%d,%d", i, -1);
return 0;
#include<stdio.h>
int main()
{
int a = - - 2;
printf("%d", a);
return 0;
}
A) 2 B) -2 C) 1 D) Error
Question 58
Predict the output:
#include<stdio.h>
int main()
{
int a = - - 2;
printf("%d", a);
return 0;
}
A) 2 B) -2 C) 1 D) Error
Ans: A
Question 59
Which of the following special symbol is allowed in a variable
name?
A) *(asterisk)
B) _(underscore
C) .(dot)
D) –(hyphen)
Question 59
Which of the following special symbol is allowed in a variable
name?
A) *(asterisk)
B) _(underscore
C) .(dot)
D) –(hyphen)
Ans: B
THANK YOU