0

Programming Test

Description: Practice Tests to increase the Skills covers all concepts of Information Technology, Get prepared for GATE, BCA, B.Sc-IT,M.Sc-IT, MCA Entrance
Number of Questions: 25
Created by:
Tags: Practice Test Practice Tests GATE BCA B.Sc-IT M.Sc-IT MCA Entrance Programming Computer Basics Data Communication & Networks Data Structures Operating System Computer Hardware Information Technology Database
Attempted 0/24 Correct 0 Score 0

#include<stdio.h> #include<conio.h> main() { int a[3],i; for(i=0;i<3;i++) a[i]=i++; for(i=0;i<3;i++) printf(" %d",a[i]); }

  1. 0 Garbage Value 2

  2. 0 1 2

  3. 1 2 3

  4. None of the above


Correct Option: A

void main() { int a = 123, b = 456; a ^= b ^= a ^= b; printf("%d %d",a,b); }

  1. 123 456

  2. 123 123

  3. 456 456

  4. 456 123


Correct Option: D

void main() { int a=5,b=4,c=10; *((a>b) ? &a : &b) = (a+b>c); printf(%d %d,a,b); }

  1. Syntax error

  2. Fatal error

  3. 0 4

  4. System hangs


Correct Option: C

void f(int *ip) { static int dummy = 5; ip = &dummy; printf(%u,ip); } void main() { int *ip; f(ip); printf(%u,ip); }

  1. Some values

  2. 0 Some value

  3. Error

  4. None of the above


Correct Option: A

void main() { int realarray[2]={1,2}; int *array = &realarray[-1]; int i; for(i=0;i<2;i++) { printf(" %d",*array); array++; } }

  1. Error

  2. Garbage Value 1

  3. 0 1

  4. 1 2


Correct Option: B

What will be the output of the given function?void main() { int a=1,b=2,c=3,d=4; printf("%d",!a?b?!c:!d:a); }

  1. 1

  2. 0

  3. No output

  4. Error


Correct Option: A

int main() { int a=500,b=100,c=30,d=40,e=19; a+=b-=c*=d/=e%=5; printf("%d %d %d %d %d",a,b,c,d,e); }

  1. 0 -200 300 10 4

  2. 300 -200 300 10 4

  3. -200 300 10 4 0

  4. 100 -200 300 4 10


Correct Option: B

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

  1. 20 20

  2. Garbage Value 20

  3. 0 20

  4. Linker Error


Correct Option: D

#define Str(x) #x #define Xstr(x) Str(x) #define OP plus void main() { char *opname = Xstr(OP); printf(%s,opname); }

  1. Plus

  2. Compilation Error

  3. Runtime Error

  4. Linker Error


Correct Option: A

void main() { int i; for (i=5; ++i; i-=3) printf("%d ",i); }

  1. Program Hangs

  2. No Output

  3. 6 4 2

  4. 5 2


Correct Option: C

What will be the output of the following program? void main() { int val=1234; int* ptr=&val; printf("%d %d",val,*ptr++); }

  1. 1234 1234

  2. 1235 1235

  3. 1234 1235

  4. 1235 1234


Correct Option: A

What will be the output of the following program?

void func() { printf("Testing...Done"); } void main() { func; func(); }

  1. Compile-Time Error

  2. Testing...Done

  3. Testing...Done

  4. None of these


Correct Option: B

A signed int bitfield 1-bit wide can only hold the values

  1. 0 and 1

  2. 0 and -1

  3. 0, 1 and -1

  4. None of these


Correct Option: A

What will be the output of the following program? void main() { int i; float a[5]; for (i=0; i<5; i++) a[i] = (printf, ("%d",i/10.0)); for (i=0; i<5; i++) printf("%.1f ",a[i]); }

  1. Compile-Time Error

  2. 0.0 0.0 0.0 0.0 0.0

  3. 0.0 0.1 0.2 0.3 0.4

  4. 1.0 1.0 1.0 1.0 1.0


Correct Option: A

void main() { int ; _=100; printf("%d",); }

  1. 100

  2. Linker Error

  3. Run Time Error

  4. Compiler Error


Correct Option: A

#define big(a,b) a > b ? a : b #define swap(a,b) temp=a; a=b; b=temp; void main() { int a=3,b=5,temp=0; if ((3+big(a,b)) > b) swap(a,b); printf("%d %d",a,b); }

  1. 3 0

  2. 5 3

  3. 3 5

  4. 5 0


Correct Option: B

Evaluate the following:

int fn(int v) { if(v==1 || v==0) return 1; if(v%2==0) return fn(v/2)+2; else return fn(v-1)+3; } for fn(7);

  1. 10

  2. 11

  3. 1

  4. 0


Correct Option: B

What does the following code do?

void afunction(int *x) { x=new int; *x=12; } int main() { int v=10; afunction(&v); printf(“%d”,v); }

  1. Outputs 12

  2. Outputs 10

  3. Outputs the address of v

  4. No output


Correct Option: B

What does the line containing "break;" do in the following code?

void afunction() { if(1) { break; afunction(); printf("Error"); } }

  1. Breaks out of the if statement

  2. Exits the function

  3. Compiler error

  4. Nothing


Correct Option: C

void main() { int choice=2; switch(choice) { default: printf("Default1");

case 1: printf("Case1"); break;

default: printf("Default2"); } }

  1. Compile-Time Error

  2. Default1Case1

  3. Default2

  4. Default1


Correct Option: A

What are the types of variable f2 and p2 in the following declaration?

#define floatptr float * #define int * intptr

floatptr f1,f2; intptr p1,p2;

  1. float, int pointer

  2. float pointer, int pointer

  3. float, int

  4. float pointer, int


Correct Option: A

What would be the output of the following?

#define SQR(x) x*x main() { int a,b=3; a=SQR(b+2); printf(“%d”,a); }

  1. 25

  2. 11

  3. Error

  4. Garbage Value


Correct Option: B

What will be the output of the following program?

void func() { printf("Testing...Done"); } void main() { func; func(); }What would be the output of the following?

main() { int a=10,b; a>=5?b=100:b=200; printf("%d",b); }

  1. 100

  2. 200

  3. Compiler Error

  4. None of the above


Correct Option: B

What would be the output of the following?

main() { int i=4; switch(i) { default: printf(“A”); case 1: printf(“B”); break; case 2: printf(“C”); break; case 3: printf(“D”); break; } }

  1. A

  2. B

  3. All the above

  4. None of the above


Correct Option: D
- Hide questions