GLOBAL EDGE Fresher Placement Question Paper
* (1) : TRUE */
1. What is the Output of the Program ?
main()
{
int a = 1;
#define p a
printf(“%d %d “,a++,p++) ;
}
a) 1, 0
b) 2, 0
c) 1 2
d) none of the above
Ans (d)
2. What is the Output of the Program ?
#include<stdio.h>
main()
{
#include<stdio.h>
int a = 90 ;
printf(“%d”,a) ;
}
a) 90
b) compilation error
c) linker error
d) runtime error
Ans (a)
3. What is the Output of the Program ?
main()
{
main() ;
}
a) compilation error
b) runtime error
c) executes until the stack overflows(1)
d) none of the above
Ans (c)
4. What is the Output of the Program ?
#define max “hello”
main()
{
printf(max) ;
}
a. compilation error
b. Preprocessing error
c. runtime error
d. hello
Ans (d)
5. What is the Output of the Program ?
#define max main()
main()
{
max ;
printf(“hello wolrd\n “) ; }
a. compilation error
b. Preprocessing error
c. runtime error
d .executes until the stack overflows
6. What is the Output of the Program ?
typedef int *p ;
main()
{
int a = 90 ;
p p1 ;
p1 = &a ;
printf(“%d”,*p1) ;
}
a. 90
b. compilation error
c. runtime error
d. none of the above
Ans (a)
7. What is the Output of the Program ?
main()
{
int i = 1 ;
printf(i ?”one” : “zero”) ;
}
a. one
b. zero
c.error
d. both and b
Ans (a)
8. What is the Output of the Program ?
main()
{
int i = 1 ;
printf(“%d”,i ? 1 : 0) ;
}
a. 1
b. 0
c. error
d. none of the above
9. What is the Output of the Program ?
main()
{
int a = 90 , b = 100 ;
a++ ;
a = (a ^ b) ^ (a = b );
b = a^b^a ;
–a ;
printf(“%d %d”,a++,b++) ;
}
a. 90 100
b. 100 90
c. 101 91
d. 91 101
Ans (a)
10. What is the Output of the Program ?
main()
{
int a = 10 , b = 100 ;
swap(&a , &b) ;
printf(“%d %d”,a,b) ;
}
swap(int *a , int *b)
{
*a = *a + *b ;
*b = *a – *b ;
*a = *a – *b ;
swap1(&a , &b) ;
}
swap1(int **a , int **b)
{
**a = **a + **b ;
**b = **a – **b ;
**a = **a – **b ;
}
a. 100 10
b. 10 100 (1)
c lvalue is required in fun main
d. error !!
Ans (b)
11. What is the Output of the Program ?
main()
{
void *ptr ;
int a = 10 ;
ptr = &a ;
printf(“%d”,*ptr) ;
}
1. error
2. 10
3. 20
4. none
Ans (1)
12. What is the Output of the Program ?
main()
{
void *ptr ;
int a = 90 ;
char *ptr1 = “hello” ;
ptr = a ;
ptr = ptr1 ;
}
a. executes w/o any error
b. compilation error
c. runtime error
d.none
Ans (a)
13. What is the Output of the Program ?
main()
{
char *p = “helloo” ;
char *p1 = “strcat” ;
while((*(p++) = *(p1++)) != ”)
{
;
}
}
a. error
b. address is copied
c. contents are copied
d . none
Ans (c)
14. What is the Output of the Program ?
int g = 10 ;
main()
{
int a = 10 ;
printf(“%d”,a) ;
}
int g ;
a. 10
b. 11
c. error
d. none
Ans (a)
15. What is the Output of the Program ?
main()
{
int a = 1 ;
int b = 0 ;
a = a++ + –b * a++ ;
printf(“%d”,a) ;
}
a. error
b. none
c. 1
d .2
Ans (d)
16. What is the Output of the Program ?
struct s
{
int si;
union u
{
float uf;
char uc;
};
};
main()
{
printf(“%d”,sizeof(struct s));
}
a. 8
b. 3
c. 6 @
d. 7
17. What is the Output of the Program ?
struct st
{
int a;
char b;
}
main()
{
}
a. struct st is return type of main@
b. main is a variable of struct st.
c. Compilation error
d. Run time error
Ans (A)
—————————————————–
18. What is the Output of the Program ?
typedef struct info
{
int i;
char b;
} node;
main()
{
struct info node1;
node1.i=55;
printf(“%d”,node1.i);
}
a. 55
b. Not possible to use struct info
c.Compilation error
d. Garbage value.
Ans (A)
19. What is the Output of the Program ?
struct a
{
int i;
int display()
{
printf(“hello world\n”);
}
};
main()
{
strcut a vara;
vara.display();
}
a. hello
b. hello world
c. Compile time error
d. garbage
20. What is the Output of the Program ?
struct a
{
int (*ptr)();
};
int display()
{
printf(“Global Edge\n”);
}
main()
{
struct a structa;
structa.ptr=display;
structa.ptr();
}
A. Global Edge
B. Address of display function
C. address of structa
D.Error
Ans (A)
21. What is the Output of the Program ?
typedef int *ABC;
typedef ABC XYZ[10];
int main()
{
XYZ var;
}
1. var is an array of integer pointers.
2. var is a pointer to an integer array.
Options:
a) only 1 is correct.
b) only 2 is correct.
c) both 1 and 2 are correct.
d) typedef statements are in wrong order.
Answer : b
22. What is the Output of the Program ?
union tag
{
int a;
char x;
char y;
}name;
(Assume Storage is Little Endian technique)
int main()
{
name.a=258;
printf(“\n x = %d y = %d “,name.x,name.y);
}
a) x = 1 y = 1
b) x = 2 y = 2
c) x = 1 y = 2
d) x = 2 y = 1
Answer : b
23. Consider the Program,
int main()
{
int a[20];
int *p,*q,val;
p = &a[0];
q = &a[10];
val = q – p;
printf(“p %u q %u val %d “,p,q,val);
}
Assume p = 1000, what is the value of q and val ?
a) q = 1020 val = 20
b) q = 1020 val = 10
c) q = 1010 val = 10
d) q = 1010 val = 20
answer : b
24. Consider the Program,
struct key
{
char *word[2];
int count;
char c;
}abc;
int main()
{
printf(“\nsize %d”,sizeof(abc));
}
25. What is the size of abc?
a) 8
b) 7
c) 6
d) 5
Answer : b
26. What is the output of the following program ?
main()
{
int a;
fun();
printf(“%d”,a);
a=50;
}
fun()
{
int i;
*(&i+4) = 100;
}
a. 50
b. Garbage value
c. 100
d. Compiler error
27. What is the output of the program ?
main()
{
#define x 5
int b;
b = x;
printf(“%d”,b);
}
a. Compiler Error
b. Runtime error
c. Garbage value
d. 5
28. What is the output of the following program ?
main()
{
int a; #define y 10
a=y;
printf(“%d”,a);
}
a. 10
b. Compiler error
c. Run-time error
d. Garbage value
29. What will be printed on the screen ?
#define s -50
main()
{
int s;
#ifdef s
printf(“Hell\n”);
#else
printf(“Heaven\n”);
#endif
}
a. Hell
b. Heaven
c. Compilation error
d. HellHeaven
30. Which of ‘Arrays’ or ‘pointers’ are faster ?
a. Arrays
b. pointers
c. Both take same time
d. Can’t say
31.How many times can a comment be nested ?
A)COMMENT_NEST_LIMIT times
B)COMMENT_LIMIT times
C)ONE time
D)Not even Once (R)
32. Which one MUST be correct in the following statements ?
A)All Identifiers are keywords
B)All Keywords are Identifiers
C)Keywords are not Identifiers
D)Some keywords are Identifiers
Ans (A)
33. Select the choice which is wrong ?
A)’volatile’ is a reserved word
B)’volatile’ is a keyword
C)’volatile’ is a data type
D)’volatile’ is a Identifier
Ans (C)
34. Consider the following Program
main()
{
int i,j;
i = 06;
j = 09;
printf (“%d %d\n”,i,j);
}
35. What would be the output ?
A)6 9
B)6 11
C)06 09
D)Compilation Error
36. What happens when we compile this program ?
# undef __FILE__
# define __FILE__ “GLOBALEDGE”
main()
{
printf(“%s\n”,__FILE__);
}
A)Compilation Error
B)Run-Time Error
C)Compiles But gives a Warning
D)Compiles Normally
37. What happens when we compile this program ?
# define LINE
# define NAME “GESL”
main()
{
printf(“%d “%s\n”,LINE,NAME);
}
A)Compilation Error
B)Compiles but Warns
C)Syntax Error
D)Compiles Normally
38.
int main()
{
int i = 5;
if(1)
{
static int i;
i++;
printf(“%d”, i);
}
printf(“%d”, i);
}
a. error
b. 5,0
c. 5,1
d. 1,5
Ans (d)
39.
int main()
{
int a[4] = { 23, 67, 90};
printf(” %d”, a[3]);
}
a. junk
b. error
c. 0 (ans)
d. 1
40.
int main()
{
int i = 1, 2;
printf(“%d”, i);
}
a. 1
b. 2
c. error
d. none
Ans (c)
41.
int main()
{
int i;
for( i=0; ; i++)
{
i = i+2;
break;
printf(“%d”, i);
}
}
a. 0
b. 2
c. error
d. none (ans)
Ans (d)
42.
int main()
{
int i;
i = 1, 2;
printf(“%d”, i);
}
a. 1 (ans)
b. 2
c. error
d. none
43.
#include<stdio.h>
int i =20;
int maxlen = i;
int main()
{
int j = i;
printf(“i=%d , j=%d\n”, i , j);
}
a) i=20 , j=20
b) i=20 , j=junk
c) error
d) none
Ans.(c)
44.
int main()
{
int i =10;
printf(“%d”, j);
printf(“%d”,i);
}
int j = 20;
a) j=20 , i=10
b) j=junk , i=10
c) compile time error
d) runtime error
Ans (c)
45.
int i =20;
int i,j=10;
main()
{
int j =20;
printf(“i=%d , j=%d\n”, i, j);
}
a) redeclaration error
b) i=20 , j=10
c) i=20 , j=20 (ans)
d) none
46.
int main()
{
int k=2, i =10;
while(k–)
{
printf(“%d\n”,disp(i));
}
}
disp(int k)
{
static int i=0;
return i=i+k;
}
a) 10, 10
b) 10, 20 (ans)
c) 20, 10
d) none
47) header files usually contains
a)only definitions
b)only declarations (ans)
c)both
d)compiled code for functions
46) int main()
{
int i =3;
while(i–)
{
int i =10;
printf(“%d”,i);
}
}
a) 10, 9, 8, 7, …..1
b) 10, 10, 10, 10, …
c) 10, 10, 10 (ans)
d) none
48.
char s[] = “hello world”;
printf(“%s…%d”,s,strlen(s));
What is the output?
(a) hello…5
(b) hello world…12
(c) hello…12
(d) compile time error
ans : (a)
49.
printf(“%%% s”,”hello”);
What is the output?
(a) %%%s
(b) %%%
(c) %hello
(d) hello
ans : (c)
50) What does fgetc return ?
(a) char
(b) int
(c) unsigned int
(d) void
ans : (b)
51.
int i = 24;
printf(“%xd”,i);
What is the output?
(a) 18
(b) 24
(c) 18d
(d)compile time error
ans : (c)
(52)
What is return type of freopen
(a) int*
(b) FILE*
(c) int
(d) void
ans : (b)
53.
struct node
{
int i;
} ;
main()
{
struct node n1;
printf(“%d”,n1.i);
}
o/p of the program:
a. 0
b. Garbage value
c. error.
4.warning
Ans: b
54.
struct node_tag
{
int i;
struct node_tag *pt;
} ;
main()
{
printf(“%d”,size(node_tag));
}
o/p of the program:
a). 4
b). 6
c).Garbage value
d).error
Ans:d
55.
typedef struct node_tag
{
int i=0;
int j;
} node;
main()
{
node n1;
printf(“%d”,n1.i);
}
o/p of the program:
1. 0
2. warning
3.Garbage value
4.error
Ans: d
56) struct
{
int i;
}node ;
main()
{
printf(“%d”,node.i);
}
o/p of the program:
(a). 0
(b). Garbage value
(c). error.
(d). warning
Ans: (a)
(57) struct node_tag
{
int a;
struct node_tag *pt;
} ;
main()
{
struct node_tag n1;
n1.pt=&n1;
n1.pt->a=5;
printf(“%d”,n1.a);
}
o/p of the program:
(a). error
(b). warning
(c). 5
(d).Garbage value
Ans: (c)
-58) int n;
scanf(“%d”,n);
what is the output?
a)read 1 integer value
b)compile time error
c)runtime error
d)reads 0
Ans (c)
59) strchr(s,c)
what this will do?
a)return pointerto first ‘c’ in ‘s’ or NULL if not present
b)return pointerto last ‘c’ in ‘s’ or NULL if not present
c)concatenate c to s in the beginning
d)concatenate c to s at the end
Ans :a
(60) When calloc() is called memory is initialised to
a)Garbage
b)NULL
c)0
d)-1
Ans (c)
-61. (void *) is called
(a)pointer to void
(b)pointer to any data type
(c)generic pointer
(d)None of the above
Ans (c)
-62. What the putchar() will return on error
a)0
b)EOF
c)NULL
d)-1
Ans (b)
63) what is the output of the following ?
i=5;
i=i++ * i++;
printf(“%d”,i);
a)30
b)49
c)25
d)27
Ans (d)
(64). what is the output of the following ?
i=5;
printf(“%d”,i++ * i++);
a)30
b)49
c)25
d)37
Ans (c)
-65) #include<stdio.h>
int main(void)
{
putchar(“0123456789ABCDEFGHIJKL” [16 & 17 ] );
return NULL;
}
Choice(s) :
a) Error
b) No Output
C) Garbage
d) G
66) #include<stdio.h>
int main()
{
char *p = “Welcome To GESL\n”;
*(p+10);
fprintf(stderr,”%s”,p);
return ‘c’;
}
Choice(s) :
a) prints “GESL” to stderr.
b) Error
C) Garbage
d) prints “Welcome To GESL” to screen
67) #define islower(c) ( ‘a'<=(c) && (c)<=’z’ )
#define toupper(c) ( islower(c) ? (c)-(‘a’-‘A’) : (c) )
main()
{
char *P=”masonic dozens DEIfy forelock too …”;
while(*P)
printf(“%c”,toupper(*P++));
}
—————————————————
Choice(s) :
———
a) Error
b) ORIGINALTO
C) MSDOSUSART
d) SIDEEfFECT
—————————————————
Ans d)
-68) #include<stdio.h>
int main(void)
{
puts(“helloworld”);
}
Choice(s) :
a) Error
b) hello$^@$S
C) hello
d) world$%^#^
—————————————————
-69) #include<stdio.h>
typedef char (*PFI) () ;
char main(int argc,char *argv[],char *environ[])
{
PFI a = main;
printf(“%s”,a);
}
Choice(s) :
a)Compile Time Error
b)Infinite Loop
c)Prints some garbage
d)Run Time error
Answers :
——-
1) (d) G
2) (d) Prints “Welcome To GESL” to Screen
3) (d) SIDEEfFECT
4) (c) Hello
5) (c) Prints Some Garbage
70)
union u
{
int ival;
float fval;
char *sval;
}
size of u is
a) 8 bytes
b) 4 bytes
c) compile time error
d) 12
Ans (b)
71) struct x
{
int i; int j;int k;
} ;
struct x *p;
struct x arr[3];
p =&arr[0];
p++;
what is p pointing to
a) pointing to i of arr[0]
b) pointing to j of arr[0]
c) pointing to k of arr[1]
d) pointing to i of arr[1]
Ans : (d)
72)
struct a
{
int b;
};
struct b
{
int b;
};
int main()
{
struct a first;
struct b second;
first.b =10;
second = first;
printf(“%d”,second.b);
}
a) 10
b) garbage
c) compile error
d) run time error
Ans: c
73) struct a
{
int x;
float y;
double z;
struct a b;
};
a) no error
b) compile error
c) run time error
d) none of the above
ans : b
74) struct a{
struct b
{
int a;int b;
}c;
int *ptr;
}d;
d.ptr=&d.c.a;
a) compile error
b) syntax error
c) Both a and c
d) none of the above
ans : d
—————————————x——————————————-x————————————————x———————————————-x
1) Uninitialized static variables are intitialized during
a) run time
b) compile time
c) initialized by operating system
d) initialized by the linker
ans : b
2) Given the height of a binary tree what is the maximum number
nodes?
a) 2^(n+1) -1
b) 2^(n) -1
c) 2^(n-1) -1
d) none
ans : a
3) which of the following sorting mechanism performs best in worst
case
a) bubble sort
b) insertion sort
c) heap sort
d) quick sort
ans : c
4) which of the following is correct (^ is epsilon)
a) context sensitive grammers do not allow ^
b) context free grammers are subset of context sensitive grammer
c) context free grammer allows ^
d) all of the above
5) which of the following is not correct
a) canonical LR comes under bottom up parsing technique
b) LL1 grammer comes in predictive parsing
c) predictive parsing comes in top down parsing technique
d) LALR is more powerfull than canonical LR
ans : d
***************************************************
***************************************************
***************************************************
***************************************************
1)
#include<stdio.h>
int main(void)
{
int *intPtr ;
intPtr = (char*)malloc(sizeof(10));
printf(“\n The starting address is %d \n “,intPtr);
return 0;
}
a) Compilation Error
b) Runtime Error
c) Will give a Warning , but run any way
d) neither warning nor error
CORRECT ANSWER : c
—————————–
2)#include<stdio.h>
int main(void)
{
FILE *fp1,*fp2;
int c;
fp1 = fopen(“testing”,”a”);
fp2 = fopen(“testing”,”w”);
while( (c = getchar()) != ‘\n’)
{
fputc(c,fp1);
}
return 0;
}
/*a) Compilation Error
b) Runtime Error
c) contents of file testing are appended
d) contents of file testing are overwritten
CORRECT ANSWER : d */
——————————————-
3.#include<stdio.h>
int main(void)
{
int intNum1,intNum2,num = 1,i;
printf(“\nEnter first number \n”);
scanf(“%d”,&intNum1);
printf(“\nEnter second number \n”);
scanf(“%d”,intNum2);
for(i = 0;i<=3;i++)
{
num = intNum1 * intNum2 * num;
}
printf(“\n num = %d ” , num);
return 0;
}
/*a) Compilation Error
b) Runtime Error
c) Successful execution
d) Junk Value
CORRECT ANSWER : d */
——————————————————-
4).#include<stdio.h>
int main(void)
{
char str[5];
char *newstr;
printf(“\nEnter first string \n”);
scanf(“%s”,&str);
printf(“\n The string you have entered is %s “,str);
newstr = gets(str);
printf(“\n num = %s ” , newstr);
printf(“\n the new string is %s “,newstr);
return 0;
}
/*a) Compilation Error
b) Runtime Error
c) Successful execution
d) Junk Value
CORRECT ANSWER : a */
——————————————-
5) #include<stdio.h>
int main(void)
{
FILE *fp;
char *str ;
char *newstr;
fp = fopen(“source”,”r”);
newstr = fgets(str,5,fp);
printf(“\n The new str is %s ” ,newstr);
return 0;
}
/*a) Compilation Error
b) Runtime Error
c) Successful execution
d) Segmentation Fault
CORRECT ANSWER : d */
1) int a=1,b=0, x;
x = a++ && ++b;
printf(“%d %d %d “,a,b,x );
output ?
a) 1 1 2 b) 2 1 0 c) 2 0 2 d) 2 1 1
ans: d
2) char *fn();
main() {
char *s;
s = fn();
printf(“%s\n”,s );
}
char *fn()
{ return “Hello”; }
output is ?
a) null b) garbage c) Hello d) Compilation Error
ans: c
3) int i;
for( i=0; i<10-1; i+=2 );
i+= 2;
printf(“i = %d\n”, i );
output is ?
a) 12 b) 11 c) 10 d) 13
ans: a
4) what is the output of the following program ?
main()
{
int i;
i = f();
printf(“%d”,i );
}
f()
{ return 1,2,3; }
a) 1 b) Compilation error c) 2 d) 3
ans: d
5) What is the difference between ++*ip and *ip++ ?
a) both increment value
b) ++*ip increment value and *ip++ increment address
c) both increment address
d) ++*ip increment address and *ip++ increment value
ans: b
6) What is the output of the following program ?
# include <stdio.h>
int
main ( void )
{
int x, y, z;
x = 2, y = 4;
z = x && y;
printf(“z = %d\n”, z );
}
1) 1
2) 0
3) None of these
4) 8
Ans = 1
7) What is the output of the following program ?
# include <stdio.h>
int
main ( void )
{
int x = 48;
printf(“x = %s\n”, x );
}
1) 10
2)0
3) Run Time Error
4) Compilation Error
Ans = 3
8) What is the output of the following program ?
# include <stdio.h>
# define ONE 1
# define TWO 2
# define ONE TWO
# define TWO ONE
int
main ( void ) {
printf(“ONE = %d, TWO = %d\n”, ONE, TWO );
}
1. ONE = 1, TWO = 2
2. TWO = 1, ONE = 2
3. Compilation Error
4. None of these
Ans = 3
9) If the command line arguments for the following program are <a.out>
and <GlobalEdgeSoftwareLtd>, what is the output of the program ?
# include <stdio.h>
int
main( int iargu, char **argvar ) {
printf(“output = %s\n”, *argvar[1] );
}
1. GlobalEdgeSoftwareLtd
2. G
3. Compilation Error
4. Run Time Error
Ans = 4
10) What is the output of the following ?
# include <stdio.h>
void fun( int, int );
int main ( void )
{
fun( 12, ( 13, ( 14, 15 ) ) );
return 0;
}
void fun( int x, int y )
{
printf(“x = %d,y = %d\n”, x, y );
}
1. x = 12, y = 13
2. x = 14, y = 15
3. x = 12, y = 15
4. Syntax Error( Too Many Arguments to fun() )
Ans = 3