Top Banner
C APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic expression- 5+3*2%10-8*6 a) -42 b) -37 c) -28 d) -32 Q2. Mark the output of the statement- int a=10; printf("%d &i",a,10); a) 10 b) 10 10 c) Error d) None of these Q3. The output of the following statement- printf("%X%x%ci%x",11,10,'s',12); a) error b) Bas94c c) basc d) none of these Q4. Output of the following statement- int a = 4, b = 7, c; c = a = = b; printf("%i", c); a) 0 b) 1 c) error d) garbage value
12

C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

Mar 29, 2018

Download

Documents

lehuong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

C APTITUDE QUESTIONS

Q1. Mark the output of the given arithmetic expression-

5+3*2%10-8*6

a) -42

b) -37

c) -28

d) -32

Q2. Mark the output of the statement-

int a=10; printf("%d &i",a,10);

a) 10

b) 10 10

c) Error

d) None of these

Q3. The output of the following statement-

printf("%X%x%ci%x",11,10,'s',12);

a) error

b) Bas94c

c) basc

d) none of these

Q4. Output of the following statement-

int a = 4, b = 7, c; c = a = = b; printf("%i", c);

a) 0

b) 1

c) error

d) garbage value

Page 2: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

Q 5. Output of the given statements-

int a = 5, b = 2, c = 10, i = a>b

void main()

{

printf("hello"); main();

}

a) 1

b) 2

c) 3

d) infinite number of times

Q6. Output of the given statement-

int x[3] = {0,1,2}; printf("%d %d %D",x[2], x[1], x[0]);

a) 000

b) 210

c) 021

d) 02%D

Q7. Output of the given statement-

printf( 3 + "goodbye");

a) dbye

b) odbye

c) bye

d) goodbye

Q8. Output of the following statement-

long int a = scanf("%ld%ld", &a, &a);

printf("%ld", a);

a) error

b) 2

c) 0

d) garbage value

Page 3: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

Q9. Output of the following program-

#include

void main()

{

int a = 2;

switch(a)

{

case 1: printf("goodbye"); break; case 2: continue; case 3: printf("bye"); } } a) bye b) goodbye c) byegoodbye d) error Q10. Output of the following statement- int i = 1, j; j=i----2;

printf("%d", j); a) 2 b) -3 c) 3 d) error Q11. Mark the output of following program- #include main() { int x, y = 10; x = y * NULL; printf("%d", x); } a) 10 b) 0 c) error d) garbage value

Page 4: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

Q12. Mark the output of following statement- char x[ ] = "hello hi"; printf("%d%d", sizeof(*x), sizeof(x)); a) 29 b) 18 c) 88 d) 19 Q13. Mark the output of the following statement-

void main()

{

int a=10, b=20;

char x=1, y=0;

if(a, b, x, y)

{

printf("MONK");

}

}

a) MONK

b) ONK

c) Compilation Error

d) No Output

Q14. Mark the output of the following statement-

int i = 3;

printf("%d%d", i, i++);

a) 34

b) 44

c) 43

d) 33

Q15. Mark the output of statement 7.5 % 3-

a) 1.5 b) 1 c) No output d) Error

Page 5: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

Q16. The three standard files which can be accessed by any program in C language are-

a) Standard error file, standard output file, standard input file

b) stdin, stderr, stdout

c) Keywords, stderr, screen

d) All of above

e) None of above

Q.17 What is an identifier in C language?

a) Name of thing say variable or function b) Made up of letters, numerals and the underscore sign c) Contain both uppercase and lowercase letters d) All of above

Q.18 Which is the single character input/output functions-

a) scanf( ) and printf( ) b) getchar( ) and putchar( ) c) getchar( ) and printf( ) d) scanf( ) and putchar( )

Q19. The operator determining the Precedence-

a) Evaluated first b) is most important c) is fastest d) Operates on the largest number

Q20. In C language, the NULL statement doing nothing is-

a) , b) ; c) : d) .

Q21. The operators && and || are named as-

a) Arithmetic operators b) Logical operators c) Equality operators d) Relational operators

Page 6: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

Q22. Give the output of following C language code-

#include <stdio.h> void main() { int k = 8; int x = 0 == 1 && k++; printf("%d%d\n", x, k); }

a) 0 9 b) 0 8 c) 1 9 d) 1 8

Q23. Give the output of following C language code-

#include <stdio.h> void main() { 1 < 2 ? return 1: return 2; }

a) returns 1

b) Varies

c) returns 2

d) Compilation time error

Q24. Give the output of following C language code-

#include <stdio.h> int main() { int x = 2, y = 1; x *= x + y; printf("%d\n", x); return 0; } a) 6 b) 5 c) Undefined behaviour shown d) Compilation time error

Page 7: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

Q25. Give the output of following C language code-

#include <stdio.h> int main() { int x = 2, y = 2; x /= x / y; printf("%d\n", x); return 0; }

a) 2 b) 0.5 c) 1 d) Undefined behaviour shown

Q26. Give the output of following C language code-

main() { char *p; int *q; long *r; p=q=r=0; p++; q++; r++; printf("%p...%p...%p", p, q, r); }

Q27. Give the output of following C language code-

main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++)

{ printf(" %d ",*p); ++p; }

Page 8: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

}

Q28. Give the output of following C language code-

main() { extern int i; i=20; printf("%d",i); }

Q29. Give the output of following C language code-

void main() { int const * p=5; printf("%d",++(*p)); }

Q30. Give the output of following C language code-

main() { int c=- -2; printf("c=%d",c); }

Q31. Give the output of following C language code-

main() { int c=- -2; printf("c=%d",c); }

Q32. Give the output of following C language code-

main() { int i=10; i=!i>14; Printf ("i=%d", i); }

Page 9: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

Q33. Give the output of following C language code-

#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

Q34. Give the output of following C language code-

main() { clrscr(); } clrscr();

Q35. Give the output of following C language code-

enum colors {BLACK,BLUE,GREEN} main() { printf("%d).%d).%d", BLACK, BLUE, GREEN); return(1); }

Q36. Give the output of following C language code-

main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }

Q37. Give the output of following C language code-

main( ) { int a[2][3][2] = {{{2,4}, {7,8}, {3,4}},{{2,2},{2,3},{3,4}}}; printf(“%u %u %u %d \n”, a, *a, **a, ***a); printf(“%u %u %u %d \n”, a+1, *a+1, **a+1, ***a+1); }

Page 10: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

Q38. Give the output of following C language code-

main() { int i=-1; +i; printf("i = %d, +i = %d \n", i, +i); }

Q39. State the files which automatically opened whenever a C file is executed?

Q40. Give the output of following C language code-

main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }

Q41. Give the output of following C language code-

#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }

Q42. Give the output of following C language code-

main() { int k=1; printf("%d==1 is ""%s", k, k==1?"TRUE":"FALSE"); }

Page 11: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

Q43. Give the output of following C language code-

main() { int *j; { int i=10; j=&i; } printf("%d",*j); }

Q44. Give the output of following C language code-

#include<stdio.h> main() { register i=5; char j[]= "hello"; printf("%s %d",j,i); }

Q45. Give the output of following C language code-

main() { int i=_l_abc(10); printf("%d\n",--i); } int _l_abc(int i) { return(i++); }

Q46. Mark the true statements about static variables?

a) Only Global variables can be defined b) Only local variables can be defined c) Both Local and Global Variables can be defined d) None of these

Page 12: C APTITUDE QUESTIONS - OurEdu Blog APTITUDE QUESTIONS Q1. Mark the output of the given arithmetic ... (str2),sizeof("abcd")); } Q41. Give the output of following C language code- …

Q47. An ampersand used in front of the pointer variable gives

a) Address of the value b) Value present at the address c) Depends on the actual scenario d) None of these