0

Programming (C/C++)

Description: Test your C skill in programming language for campus placements by free online preparation and practice paper tests
Number of Questions: 30
Created by:
Tags: C Skills Test Java Skill Test DBMS Oracle PHP Computer Application Placement Papers MCA Entrance Programming Fundamentals of Computer Programming Letter JKL Synonyms Insert the Missing Character Odd One Out Classification Blood Relations Blood Relation
Attempted 0/30 Correct 0 Score 0

What will be the output of the following function?

include <stdio.h>

void main() { int a[5] = {5,1,15,20,25}; int i,j,m; i = ++a[1]; j = a[1]++; m = a[i++]; printf(“%d %d %d”,i,j,m); }

  1. 2 1 15

  2. 1 2 5

  3. 3 2 15

  4. 2 2 2


Correct Option: C

What will be the output of the following function?

main() { printf(“RamanDeep”); }

  1. RamanDeep

  2. Raman Deep

  3. Deepn

  4. None of these


Correct Option: C

(I) In C, all the function except main() can be called recursively. (II) If return type for a function is not specified, its default is int. (III) A function cannot be defined inside another function. Which of the above statements are true?

  1. I, II, III

  2. II, III

  3. I, II

  4. None of these


Correct Option: C

Which of the following statement correctly obtains the remainder on dividing 5.5 by 1.3?

  1. Rem = 5.5 % 1.3

  2. Rem = modf(5.5,1.3)

  3. Rem = fmod(5.5,1.3)

  4. We cannot determine the reminder while doing floating point division.


Correct Option: C

Which of the following is incorrect? A recursive function

  1. calls itself

  2. is equivalent to the loop

  3. has termination condition

  4. does not return a value


Correct Option: D

Switch cannot have a ______ type value?

  1. int

  2. char

  3. float

  4. none of these


Correct Option: C

(A) If malloc() successfully allocates memory then returns the number of bytes it has allocated. (B) malloc() returns a float pointer if memory is allocated for storing float. (C) malloc() returns a NULL if it fails to allocate request memory. Which of the above statements are true?

  1. A, B, C

  2. B, C

  3. C

  4. None of these


Correct Option: C

What will be the output of the following function?

define DIM1(array,type) sizeof(array)/sizeof(type)

int DIM2(int array[]) { return(sizeof(array)/sizeof(int)); } void main() { int arr[10]; printf(“%d %d “, DIM1(arr,int), DIM2(arr)); }

  1. 10 10

  2. 10 1

  3. 1 10

  4. None of these


Correct Option: B

Pick the odd one out.

  1. Malloc()

  2. Calloc()

  3. Realloc()

  4. Free()


Correct Option: D

What will be the output of the following function?

include <stdio.h>

void main() { int i =2,j=2; printf(“%d %d %d %d”,i,i++,j,++j); }

  1. 3 3 3 3

  2. 3 2 3 3

  3. 2 2 2 3

  4. None of these


Correct Option: B

What will be the output of the following question?

main() { extern int out; printf(“%d”,out); } int out=100;

  1. 0

  2. Garbage value

  3. 100

  4. None of these


Correct Option: C

Match the following ||| |---|---| | (1) local variables | (a) stack | | (2) global variable | (b) register | | (3) register variable | (c) main memory | | (4) Static variable | (d) data memory |

  1. 1-a, 2-b, 3-c, 4-d

  2. 1-a, 2-d, 3-b, 4-c

  3. 1-a, 2-c, 3-b, 4-d

  4. None of these


Correct Option: B

What will be the output of the following question?

fun() {
here: printf(“pp”); } main() { int i=1; while(i<=5) { printf(“%d”,i); if(i>2) goto here; i++; } }

  1. 1 2 3 pp 4 pp 5 pp

  2. 1 2 3 4 5

  3. 1 2 pp pp pp

  4. Error


Correct Option: D

What will be the output of the following function?

main() { int a[10]; printf(%d,*a+1-*a+3); }

  1. Garbage value

  2. 4

  3. Error

  4. None of these


Correct Option: B

What will be the output of the following function?

include <stdio.h>

void main() { char str[10] = “Angel”; str[6] ='d'; printf(“%s”,str); }

  1. Angel d

  2. d

  3. Angel

  4. Error


Correct Option: C

(I) Every time we supply new set of values at command prompt, we need to recompile the program. (II) Even if integer/float arguments are supplied at command prompt, they are treated as strings. (III) The first argument to be supplied at command-line must always be the count of total argument.

Which of the above statement/s is/are true about command line argument?

  1. II

  2. I, II

  3. II, III

  4. None of these


Correct Option: A

What will be the output of the following function?

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

  1. 1

  2. 10

  3. Garbage value

  4. None of these


Correct Option: A

What will be the output of the following function?

main() { printf(%x,-1<<4); }

  1. 1111111111110

  2. -1

  3. fff0

  4. None of these


Correct Option: C

Choose the correct option among the following.

  1. Structure and union are same.

  2. Structure occupies more space then union.

  3. Union occupies more space then structure.

  4. None of these


Correct Option: B

What will be the output of the following function?

main() { char *p; printf(%d %d ,sizeof(*p),sizeof(p)); }

  1. 12

  2. 22

  3. 11

  4. None of these


Correct Option: A

What will be the output of the following function?

#define square(x) x*x main() {
int i; i = 64/square(4); printf(%d,i); }

  1. 1

  2. 64

  3. 0

  4. None of these


Correct Option: D

What will be the output of the following function?

main() { static int var = 5; printf(%d ,var--); if(var) main(); }

  1. Error

  2. 5 5 5(Infinite times)

  3. 5 4 3 2 1

  4. None of these


Correct Option: C

What will be the output of the following function?

#define int char main() { int i=65; printf(%d,sizeof(i)); }

  1. 1

  2. 2

  3. Error

  4. None of these


Correct Option: A

What will be the output of the following function?

#include<stdio.h> main() { struct xx { int x=3; char name[]=hello; }; struct xx *s; printf(%d,s->x); printf(%s,s->name); }

  1. 3 HELLO

  2. 3 hello

  3. Error

  4. None of these


Correct Option: C

(a) Associativity of “COMMA” is L à R. (b) Associativity of printf function is R à L. Which of the above is/are TRUE?

  1. (a)

  2. (b)

  3. Both (a) and (b)

  4. None of these


Correct Option: C

Given the piece of code int a[50]; int *pa; pa = a; to access the 6th element, which of the following is incorrect?

  1. *(a+5)

  2. a[5]

  3. pa[5]

  4. *(*pa+5)


Correct Option: C

What will be the output of the following function?

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

  1. NULL

  2. TRUE

  3. FALSE

  4. No


Correct Option: B

What will be the output of the following function?

main() { int i=0; for(i=0;i<20;i++) { switch(i){ case 0:i+=5; case 1:i+=2; case 5:i+=5; default i+=4; break;} printf(%d,,i); } }

  1. 0,5,9,13,17

  2. 5,9,13,17

  3. 16,21

  4. Syntax error


Correct Option: C

What will be the output of the following function?

include <stdio.h>

void main() { int k,num=30; k = (num>5 ? (num <=10 ? 100:200) :500); printf(“%d”,num); }

  1. 200

  2. 30

  3. 100

  4. 500


Correct Option: A

What will be the output of the following function?

include<stdio.h>

void fun(int *f) { *f = 10; } void main() { const int arr[5] = {1,2,3,4,5}; fun(&arr[3]); printf(“%d”,arr[3]); }

  1. 10

  2. 4

  3. 3

  4. Error


Correct Option: D
- Hide questions