Talent Battle Live Training: Tcs Specific Technicaltraining
Talent Battle Live Training: Tcs Specific Technicaltraining
TCSSpecific TechnicalTraining
P48. Consider the following series:
1,1,2,3,4,9,8,27,16,81,32,243,64,729,128,2187… This series is
a mixture of 2 series – all the odd terms in this series form a
geometric series and all the even terms form yet another
geometric series. Write a program to find the Nth term in the
odd series.
Input :
12345
Expected Output:
1is prime
2 is prime
3 is prime
4is not prime
5 is prime
P53. write a program to print following pattern
Input :7
Output:
*
**
***
****
*****
******
*******
******
*****
****
***
**
*
Q84. What is the output of the following program?
#include<stdio.h>
void f()
{
static int i;
++i;
printf("%d", i);
}
main()
{
f();
f();
f();
}
Q84
Answer: 1 2 3
Q85. What is the size of the following union definition?
#include<stdio.h>
union abc
{
char a,b,c,d,e,f,g,h;
int i;
}abc;
main()
{
printf( "%d", sizeof( abc ));
}
Q85
• Answer: 4
Q86. With givenprogram
#include<stdio.h> •I - Error in the statement ‘void f(int const i)’
•II - Error in the statement i=5.
void f(int const i)
{
i=5; A . Statements I & II are true
} B . Statements I & II are false.
main() C . Statement I is true
D . Statement II is true.
{
int x = 10;
f(x);
}
Q86.
• Answer: D (function with const. argument)
Q87. what will be the output
#include<stdio.h>
int get();
int main()
{
const int x = get();
printf("%d", x);
return 0;
} A - 40
int get() B - 20
{
return 40;
C-0
} D - Error
Q87.
• Answer: 40
Q88. Consider the 32 bit compiler. We need to store address of integer
variable to integer pointer. What will be the size of integer pointer ?
A. 2 Bytes
B. 4 Bytes
C. 6 Bytes
D. 10 Bytes
Q88.
• Answer: 2 byte
Q87. How would you round off a value from 1.66 to 2.0?
A. ceil(1.66)
B. floor(1.66)
C.roundup(1.66)
D. roundto(1.66)
Q87.
• Answer: A
Q88. Which of the following correctly shows the hierarchyof
arithmetic operations in C?
A. / + * -
B. * - / +
C. + - / *
D. / * + -
Q88
• Answer: D (BODMASRule)
Q89. Which of the following are unary operators inC?
1. !
2. sizeof
3. ~
4. &&
A.1, 2
B.1, 3
C.2, 4
D.1, 2, 3
Q89.
• Answer: D(1,2,3)
Q90. What will be output of program
#include<stdio.h>
int main()
{
static int a[20];
int i =0;
a[i] = i ;
printf("%d, %d, %d\n", a[0], a[1], i);
return 0;
}
Q90.
• Answer: 0,0,0
Q91. What will be the output of the program?
#include<stdio.h>
int main()
{
int x=4,
y, z;
y = --x;
z = x--;
printf("%d, %d, %d\n", x, y, z);
return 0;
}
Q91.
• Answer: 2,3,3
Q92. what will be the output
#include<stdio.h>
int main()
{ int a=100, b=200, c;
c = (a == 100 || b > 200);
printf("c=%d\n", c);
return 0;
}
Q92.
• Answer: 1
Q93. how many times hello will be in output?
#include<stdio.h>
int main() A. Infinite times
{ int x; B.11 times
for(x=-1; x<=10; x++) C.0 times
{ if(x < 5) D.10 times
continue;
else break;
printf(“Hello");
}
return 0;
}
Q93.
• Answer: C
Q94. What will be output of program?
#include<stdio.h>
int main()
{
unsigned int i = 65535;
/* Assume 2 byte
integer*/
while(i++ != 0) A. Infinite loop
printf("%d",++i);
printf("\n"); B. 0 1 2 ... 65535
return 0; C. 0 1 2 ... 32767 - 32766 -32765 -1 0
}
D. No output
Q95.
#include<stdio.h>
int main()
{
char ch;
if(ch = printf(""))
printf("It matters\n");
else
printf("It doesn't matter\n");
return 0;
}
Q96.
• Answer: A(Error)
Q 98. Select correct option
A. True
B. False
Q99.
• Answer: True
Q100. What will be the output of program?