Technical questions(15)
1. what is the output of the program
main()
{
int i=5;
printf("%d",fun(fun(fun(fun( fun(i))))));
}
void fun(int i)
{ if(i%2) return (i+(7*4)-(5/2)+(2*2));
else return (i+(17/5)-(34/15)+(5/2));
}
2. what is valid in cpp char *cp; const char *cpp;
1) cpp=cp; 2) cp=cpp;
3. What will be the output of the program?
#include<stdio.h>
int main()
{
typedef int LONG;
LONG a=4;
LONG b=68;
float c=0;
c=b;
b+=a;
printf("%d,", b);
printf("%f\n", c);
return 0;
}
A. 72,
68.000000
B. 72.000000,
68
C. 68.000000,
72.000000
D. 68,
72.000000
Ans-A
4. What do the 'c' and 'v' in argv stands for?
A. 'c' means
argument control 'v' means argument vector
B. 'c' means
argument count 'v' means argument vertex
C. 'c' means
argument count 'v' means argument vector
D. 'c' means
argument configuration 'v' means argument visibility
Ans-C
5. Point out the error, if any in the while loop.
#include<stdio.h>
int main()
{
int i=1;
while()
{
printf("%d\n", i++);
if(i>10)
break;
}
return 0;
}
A. There should
be a condition in the while loop
B. There should
be at least a semicolon in the while
C. The while
loop should be replaced with for loop.
D. No error
Ans-A
6. The elements of union are always accessed using & operator
A. Yes
B. No
Ans-B
7. What will be the output of the program?
#include<stdio.h>
#define CUBE(x) (x*x*x)
int main()
{
int a, b=3;
a = CUBE(b++);
printf("%d,
%d\n", a, b);
return 0;
}
8. If the size of integer is 4bytes, What will be the output
of the program?
#include<stdio.h>
int main()
{
int arr[] = {12,
13, 14, 15, 16};
printf("%d,
%d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0]));
return 0;
}
Ans- 20,4,4
9. The maximum combined length of the command-line arguments
including the spaces between adjacent arguments is
A. 128
characters
B. 256
characters
C. 67
characters
D. It may vary
from one operating system to another
Ans-D
10. Which of the following statement is correct?
A. strcmp(s1,
s2) returns a number less than 0 if s1>s2
B. strcmp(s1,
s2) returns a number greater than 0 if s1<s2
C. strcmp(s1,
s2) returns 0 if s1==s2
D. strcmp(s1,
s2) returns 1 if s1==s2
Ans-C
11. Point out the error in the program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
unsigned char;
FILE *fp;
fp=fopen("trial", "r");
if(!fp)
{
printf("Unable to open file");
exit(1);
}
fclose(fp);
return 0;
}
A. Error: in
unsigned char statement
B.
Error:unknown file pointer
C. No error
D. None of
above
Ans-C
12. Which of the following statements are correct about an
if-else statements in a C-program?
1: Every if-else statement can be
replaced by an equivalent statements using
? ; operators
2: Nested if-else statements are allowed.
3: Multiple statements in an if block are
allowed.
4: Multiple statements in an else block
are allowed.
A. 1 and 2
B. 2 and 3
C. 1, 2 and 4
D. 2, 3, 4
Ans-D
13. What will be the output of the program (myprog.c) given
below if it is executed from the command line?
cmd> myprog friday tuesday sunday
/* myprog.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%c", *++argv[1]);
return 0;
}
Ans-r
14. Input/output function prototypes and macros are defined
in which header file?
A. conio.h
B. stdlib.h
C. stdio.h
D. dos.h
Ans-C
15. What will be the output of the program?
#include<stdio.h>
int main()
{
int i;
char c;
for(i=1; i<=5;
i++)
{
scanf("%c", &c); /* given input is 'a' */
printf("%c", c);
ungetc(c,
stdin);
}
return 0;
}
A. aaaa
B. aaaaa
C. Garbage
value.
D. Error in
ungetc statement.
Ans-B
Aptitude (5)
1. Point out the error in the program (in Turbo-C).
#include<stdio.h>
#define MAX 128
int main()
{
const int max=128;
char array[max];
char string[MAX];
array[0] =
string[0] = 'A';
printf("%c
%c\n", array[0], string[0]);
return 0;
}
A. Error:
unknown max in declaration/Constant expression required
B. Error:
invalid array string
C. None of
above
D. No error. It
prints A A
Ans-A
2. There is a sorted array which is of very large size. In
that all except one number are repeated once. How to find that non repeated
number?
3. what is x here (x&&!(x&(x-1))==1)
a)x is always a prime
b)x is a power of 2
c)x is even
d)x is odd
4. Which of the
following is the correct order of evaluation for the below expression?
z = x + y * z / 4 % 2 - 1
A. * / % + - =
B. = * / % + -
C. / * % - + =
D. * % / - + =
Ans-A
5. Point out the error in the program?
struct emp
{
int ecode;
struct emp e;
};
A. Error: in
structure declaration
B. Linker Error
C. No Error
D. None of
above
Ans-A