0% found this document useful (0 votes)
290 views14 pages

Computer and Programming: C Aptitude Multiple Choice Questions and Answers

This document contains 25 multiple choice questions about computer programming and the C language. The questions cover topics like arithmetic expressions, printf/scanf statements, arrays, data types, operators, and functions. No answers are provided for the questions. Several comments on the post ask where the answers can be found.

Uploaded by

Pavithra Anandh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
290 views14 pages

Computer and Programming: C Aptitude Multiple Choice Questions and Answers

This document contains 25 multiple choice questions about computer programming and the C language. The questions cover topics like arithmetic expressions, printf/scanf statements, arrays, data types, operators, and functions. No answers are provided for the questions. Several comments on the post ask where the answers can be found.

Uploaded by

Pavithra Anandh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Computer and Programming

TUESDAY, MARCH 24, 2009

C Aptitude Multiple Choice Questions and Answers


Q1. What will be the output of the following arithmetic expression ?

5+3*2%10-8*6

a) -37
b) -42
c) -32
d) -28

Q2. What will be the output of the following statement ?

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

a) error
b) 10
c) 10 10
d) none of these

Q3. What will be the output of the following statement ?

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

a) error
b) basc
c) Bas94c
d) none of these

Q4. What will be the output of the following statements ?

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


a) 0
b) error
c) 1
d) garbage value

Q 5. What will be the output of the following statements ?

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


void main()
{ printf("hello"); main(); }

a) 1
b) 2
c) infinite number of times
d) none of these

Q7. What will be the output of the following statements ?

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

a) 03%D
b) 000
c) 032
d) 321

Q8. What will be the output of the following statement ?

printf( 3 + "goodbye");

a) goodbye
b) odbye
c) bye
d) dbye
Q9. What will be the output of the following statements ?

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

a) error
b) garbage value
c) 0
d) 2

Q10. What will be the 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) error
b) goodbye
c) bye
d) byegoodbye

Q11. What will be the output of the following statements ?

int i = 1,j; j=i--- -2; printf("%d",j);

a) error
b) 2
c) 3
d) -3

Q12. What will be the output of following program ?

#include
main()
{
int x,y = 10;
x = y * NULL;
printf("%d",x);
}

a) error
b) 0
c) 10
d) garbage value

Q13. What will be the output of following statements ?

char x[ ] = "hello hi"; printf("%d%d",sizeof(*x),sizeof(x));

a) 88
b) 18
c) 29
d) 19

Q14. What will be the output of the following statements


?
int a=5,b=6,c=9,d; d=(ac?1:2):(c>b?6:8)); printf("%d",d);

a) 1
b) 2
c) 6
d) 8
Q15. What will be the output of the following statements ?

int i = 3;
printf("%d%d",i,i++);

a) 34
b) 43
c) 44
d) 33

Q16. What will be the output of the following program ?

#include
void main()
{
int a = 36, b = 9;
printf("%d",a>>a/b-2);
}

a) 9
b) 7
c) 5
d) none of these

Q17)
int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
What value does testarray[2][1][0] in the sample code above contain?

a) 11
b) 7
c) 5
d) 9

Q18)
void main()
{
int a=10,b=20;
char x=1,y=0;
if(a,b,x,y)
{
printf("EXAM");
}
}
What is the output?

1) XAM is printed
2) exam is printed
3) Compiler Error
4) Nothing is printed

Q19)

What is the output of the following code?


#include
void main()
{
int s=0;
while(s++<10)>
# define a 10
main()
{
printf("%d..",a);
foo();
printf("%d",a);
}
void foo()
{
#undef a
#define a 50
}

1) 10..10
2) 10..50
3) Error
4) 0

Q21)

main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
What is the output of this program?

1) program will not compile


2) 10
3) god only knows
4) address of I

Q22)
What would be the output of the following program?
#include 
main()
{
char str[]="S\065AB";
printf("\n%d", sizeof(str));
}

1) 7
2) 6
3) 5
4) error

Q23)
What will be the value of `a` after the following code is executed
#define square(x) x*x
a = square(2+3)
1) 25
2) 13
3) 11
4) 10

Q24)
#include 
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( "%d -- %d\n", x, y );
}

int main()
{
func();
func();
return 0;
}

What will the code above print when it is executed?


1)
1 -- 1
1 -- 1
2)
1 -- 1
2 -- 1
3)
1 -- 1
2 -- 2
4)
1 -- 1
1 -- 2

Q25)

long factorial (long x)


{
????
return x * factorial(x - 1);
}
With what do you replace the ???? to make the function shown above return the correct
answer?
1)
if (x == 0) return 0;
2)
return 1;
3)
if (x >= 2) return 2;
4)
if (x <= 1) return 1;

Q 26)

int y[4] = {6, 7, 8, 9};


int *ptr = y + 2;
printf("%d\n", ptr[ 1 ] );
What is printed when the sample code above is executed?
1) 6
2) 7
3) 8
4) 9
.
Q27)

int i = 4;
switch (i)
{
default:
;
case 3:
i += 5;
if ( i == 8)
{
i++;
if (i == 9) break;
i *= 2;
}
i -= 4;
break;
case 8:
i += 5;
break;
}
printf("i = %d\n", i);

What will the output of the sample code above be?


1) i = 5
2) i = 8
3) i = 9
4) i = 10

Posted by Revise Your Factsat 10:36 AM


Labels: C Aptitude

8 comments:
pryoslice said...

This is a good test, but where are the answers?

April 3, 2009 9:50 AM

Bijendra said...

great work!!
hey pls post the answers also so that the people can check their ans also.

May 12, 2009 11:03 PM

manu088 said...

pls post answers ......

July 28, 2009 9:18 PM

nitin said...

where are the answers of these questions

September 15, 2009 9:54 PM

rajat said...

hey whr r d answrzzzz....


let ppl chek dem

November 14, 2009 2:09 AM

ujjwala said...

i wnt to see answers to ckeck out

December 21, 2009 9:14 PM


yogesh said...

hey change the name or title of the page.... so that people will not try to find
the answers....

December 23, 2009 8:32 AM

varsha said...

nice but i want answers

April 23, 2010 6:30 AM

Post a Comment

Newer PostOlder PostHome

Subscribe to: Post Comments (Atom)


Search Your Products

Labels

 Arrays (1)
 C Aptitude (2)
 C Library (1)
 C Programming (8)
 Computer Networks (1)
 Device Drivers (1)
 Ebooks (3)
 Embedded Developer (4)
 English learning (2)
 FAQ (1)
 Glossary (1)
 Good links (1)
 Kernel (1)
 Network (1)
 Sorting (1)
 Source Code (1)
 TCP/IP (3)
 Tutorials (3)

Blog Archive

 ▼  2009 (34)
o ►  September (4)
o ►  August (2)
o ►  July (4)
o ►  April (2)
o ▼  March (22)
 C Programs with Solution Logic
 Introduction to Arrays Sorting
 C Aptitude Multiple Choice Questions and Answers
 C Aptitude Questions and Answers
 The OSI Reference Model
 Preprocessing in C
 Placeholders for Scanf
 Other Best Links
 Device Drivers
 C Library
 Linux Kernel
 Network Programming
 Free Sample Programs
 GATE Online Library
 Questions and Answers
 Unix Shell and Programming Tutorial
 Free Ebook Links and Tutorials
 PlaceHolders for printf
 Facts About Computer and Programming
 Important facts in Writing a C Program
 Common Mistakes in C
 C Operator Precedence

Followers
About Me

Revise Your Facts


View my complete profile

Get Any Type of Book Here

You might also like