TCS Coding Programming Questions
TCS Coding Programming Questions
Answer: Option C
Explanation:
om
2. C preprocessors can have compiler specific features.
.c
w
platform
s
er
h
Answer: Option A
es
.fr
Explanation:
w
w
w
3. Preprocessor feature that supply line numbers and file names to compiler is
called?
Answer: Option D
Explanation:
None.
Answer: Option D
Explanation:
None.
Answer: Option A
Explanation:
om
6. What is the output of this C code? .c
w
sno
#define a 20
er
h
es
int main()
.fr
w
{
w
w
Answer: Option D
Explanation:
int main()
printf("%d", var);
A. 2 B. 8 C. 9 D. 10
om
Answer: Option B .c
w
Explanation:
s no
Answer: Option A
Explanation:
None.
int main()
printf("AllIndiaExams\r\nclass\n");
return 0;
}
Answer: Option B
Explanation:
int main()
const int a;
om
a = 32; .c
w
return 0;
er
h
es
}
.fr
w
Answer: Option B
Explanation:
Since the constant variable has to be declared and defined at the same time, not
doing it results in an error.
printf("AllIndiaExams.in");
return 0;
void main()
print();
Answer: Option B
om
.c
Explanation:
w
no
None.
s
er
h
int main()
w
w
w
int k;
int k;
Answer: Option A
Explanation:
There can be blocks inside block and within blocks variables have only block
scope.
Output:
$ cc pgm5.c
void main()
{
om
.c
int k = 4;
w
no
float k = 4;
s
er
h
printf("%d", k)
es
.fr
}
w
w
w
Answer: Option A
Explanation:
Since the variable k is defined both as integer and as float, it results in an error.
Output:
$ cc pgm8.c
Explanation:
Since the scope of the variable declared within a function is restricted only within
that function,
15.The name of the variable used in one function cannot be used in another
function?
Answer: Option B
Explanation:
om
Since the scope of the variable declared within a function is restricted only within
.c
w
that function, the same name can be used to declare another variable in another
no
function.
s
er
h
16. C99 standard guarantees uniqueness of ____ characters for internal names.
es
.fr
A. 31 B. 63 C. 12 D. 14
w
w
w
Answer: Option B
Explanation:
ISO C99 compiler may consider only first 63 characters for internal.
Answer: Option D
Explanation:
None.
18. Which of the following is not a valid variable name declaration?
Answer: Option C
Explanation:
A. Lower Case letters B. Upper Case letters C. Camel Case letters D. None
Answer: Option A
Explanation:
om
None. .c
w
Answer: Option A
w
Explanation:
It depends on the standard to which compiler and linkers are adhering to.
Answer: Option D
Explanation:
Answer: Option B
Explanation:
int main()
int y = 10000;
om
.c
int y = 34;
w
no
return 0;
es
.fr
}
w
w
w
Answer: Option A
Explanation:
Output:
$ cc pgm2.c
Explanation:
Answer: Option A
Explanation:
volatile is C keyword.
om
int main() .c
w
{
s no
void foo();
er
h
es
void f()
.fr
w
{
w
w
foo();
f();
void foo()
printf("2 ");
}
A. 2 2 B. 2 C. Compile time error D. Depends on the compiler
Answer: Option D
Explanation:
Even though the answer is 2, this code will compile fine only with gcc. GNU C
supports nesting of functions in C as a language extension where as standard C
compiler doesn’t.
void foo();
int main()
void foo(); om
.c
w
no
foo();
s
er
return 0;
h
es
.fr
}
w
w
void foo()
w
printf("2 ");
Answer: Option B
Explanation:
None.
28. What is the default return type if it is not specified in function definition?
Answer: Option B
Explanation:
None.
int foo();
int main()
om
int i = foo(); .c
w
}
s no
foo()
er
h
es
{
.fr
w
printf("2 ");
w
w
return 2;
Answer: Option A
Explanation:
None.
Answer: Option A
Explanation:
None.
Answer: Option A
Explanation:
None.
om
32. Which keyword can be used for coming out of recursion?
.c
w
Answer: Option B
er
h
es
Explanation:
.fr
w
none
w
w
int main()
int a = 0, i = 0, b;
a++;
continue;
}
A. 2 B. 3 C. 4 D. 5
Answer: Option D
Explanation:
none
34. Which keyword is used to come out of a loop only for that iteration?
Answer: Option B
om
Explanation: .c
w
none
s no
void main()
.fr
w
{
w
w
double k = 0;
printf("Hello");
A. Run time error B. Hello is printed thrice C. Hello is printed twice D. Hello
is printed infinitely
Answer: Option B
Explanation:
none
void main()
double k = 0;
printf("%lf", k);
om
Answer: Option C .c
w
Explanation:
s no
none
er
h
es
37. typedef which of the following may create problem in the program?
.fr
w
Answer: Option D
Explanation:
None.
A. Does not create a new type B. It merely adds a new name for some
existing type. C. Both a & b D. None of the
mentioned
Answer: Option C
Explanation:
None.
typedef struct p
int x, y;
}k;
int main()
om
struct p p = {1, 2}; .c
w
k k1 = p;
no
s
printf("%d\n", k1.x);
her
es
}
.fr
w
Answer: Option B
Explanation:
None.
SELECT fname
FROM person
Answer: Option A
Explanation:
om
.c
w
s no
er
h
es
.fr
w
w
w