Improve your score with the help of TCS Ninja programming MCQ’s with answers. Basic topics in C are covered through TCS Ninja programming MCQ’s. It will be easier for you to answer these questions if your concepts are clear in C programming. Few questions based on TCS Ninja programming and asked in previous TCS exam are mentioned below:-
1.What is a step-by-step procedure used to solve a problem called?
A. algorithm
B. operating system
C. application program
D. all of these
Answer: A
2. Consider the following three C functions:
[PI] int * g (void)
{
int x= 10;
return (&x);
}
[P2] int * g (void)
{
int * px;
*px= 10;
returnpx;
}
[P3] int *g (void)
{
int *px;
px = (int *) malloc (sizeof(int));
*px= 10;
returnpx;
}
Which of the above three functions are likely to cause problems with pointers?
Only P3
Only P1 and P3
Only P1 and P2
P1, P2 and P3
Answer: Option C
3. Assume the following C variable declaration
int *A[10], B[10][10];
Of the following expressions
1. A[2] 2. A[2][3] 3. B[1] 4. B[2][3]
which will not give compile-time errors if used as left hand sides of assignment statements in a C program?
1,2 and 4 only
2,3 and 4 only
2 and 4 only
4 only
Answer : Option A
4. Consider the C program shown below
#include<stdio.h>
#define print(x) printf("%d", x)
int x;
void Q(int z)
{
z+=x;
print(z);
}
void P(int *y)
{
int x = *y + 2;
Q(x);
*y = x - 1;
print(x);
}
main(void) {
x = 5;
P(&x);
print(x);
}
The output of this program is
1. 12 7 6 2. 22 12 11 3.14 6 6 4. 7 6 6
Answer : Option A
x=5;
P(&x);
x=*y+2=5+2=7;
Q(x);
Z=7;
Z=z+x=12 Þ print (z) =12
*y =x-1 =6 Þ print (x) =7
Print (x) =6
5. To access the services of operating system, the interface is provided by the
A) On
B) Using
C) Set
D) None of these
Answer: A
6. Which of the following is correct declaration for a pointer to a function that returns a float?