Question 1

Time: 00:00:00
Which of the following is an invalid if-else statement?

if (if (a == 1)){}

if (if (a == 1)){}

if (func1 (a)){}

if (func1 (a)){}

if (a){}

if (a){}

if ((char) a){}

if ((char) a){}

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 2

Time: 00:00:00
Which datatype can accept switch statement?

int

int

char

char

long

long

float

float

all of the mentioned

all of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 3

Time: 00:00:00
What will be the output of the following C code?

  #include <stdio.h>
  void main(){
      int i = 0;
      while (++i){
          printf("H");
      }
  }

H

H

H is printed infinite times

H is printed infinite times

Compile time error

Compile time error

Varies

Varies

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 4

Time: 00:00:00
Which of the following function declaration is illegal?

int 1bhk(int);

int 1bhk(int);

int 1bhk(int a);

int 1bhk(int a);

int 2bhk(int*, int []);

int 2bhk(int*, int []);

all of the mentioned

all of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 5

Time: 00:00:00
Functions can return structure in C?

True

True

False

False

Depends on the compiler

Depends on the compiler

Depends on the standard

Depends on the standard

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 6

Time: 00:00:00
What will be the output of the following C code?

#include <stdio.h>
  enum m{JAN, FEB, MAR};
  enum m foo();
  int main(){
      enum m i = foo();
      printf("%d\n", i);
  }
  int  foo()  {
      return JAN;}

Compile time error

Compile time error

Depends on the standard

Depends on the standard

Depends on the compiler

Depends on the compiler

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 7

Time: 00:00:00
Which of the following does not initialize ptr to null (assuming variable declaration of a as int a=0;)?

int *ptr = &a;

int *ptr = &a;

int *ptr = &a – &a;

int *ptr = &a – &a;

int *ptr = a – a;

int *ptr = a – a;

All of the mentioned

All of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 8

Time: 00:00:00
What are the elements present in the array of the following C code?

int array[5] = {5};

5, 5, 5, 5, 5

5, 5, 5, 5, 5

5, (garbage), (garbage), (garbage), (garbage)

5, (garbage), (garbage), (garbage), (garbage)

5, 0, 0, 0, 0

5, 0, 0, 0, 0

(garbage), (garbage), (garbage), (garbage), 5

(garbage), (garbage), (garbage), (garbage), 5

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 9

Time: 00:00:00
What value strcmp() function returns when two strings are the same?

-2

-2

-2

-2

Error

Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 10

Time: 00:00:00
Assume that size of an integer is 32 bit. What is the output of following program?

#include<stdio.h>
struct st

 int x;
   static int y;
};
int main()
{
printf("%d", sizeof(struct st));
return 0;
}

4

4

8

8

Compiler Error

Compiler Error

Runtime Error

Runtime Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 11

Time: 00:00:00
struct node

{  int i;
  float j;
};struct node *s[10];

The above C declaration define 's' to be

An array, each element of which is a pointer to a structure of type node

An array, each element of which is a pointer to a structure of type node

A structure of 2 fields, each field being a pointer to an array of 10 elements

A structure of 2 fields, each field being a pointer to an array of 10 elements

A structure of 3 fields: an integer, a float, and an array of 10 elements

A structure of 3 fields: an integer, a float, and an array of 10 elements

An array, each element of which is a structure of type node.

An array, each element of which is a structure of type node.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 12

Time: 00:00:00
Which of the following operators can be applied on structure variables?

Equality comparison ( == )

Equality comparison ( == )

Assignment ( = )

Assignment ( = )

Both of the above

Both of the above

None of the above

None of the above

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 13

Time: 00:00:00
What is the similarity between a structure, union and enumeration?

All of them let you define new values

All of them let you define new values

All of them let you define new data types

All of them let you define new data types

All of them let you define new data pointers

All of them let you define new data pointers

All of them let you define new structures

All of them let you define new structures

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 14

Time: 00:00:00
Which of the following true about FILE *fp

FILE is a keyword in C for representing files and fp is a variable of FILE type.

FILE is a keyword in C for representing files and fp is a variable of FILE type.

FILE is a stream

FILE is a stream

FILE is a buffered stream

FILE is a buffered stream

FILE is a structure and fp is a pointer to the structure of FILE type

FILE is a structure and fp is a pointer to the structure of FILE type

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 15

Time: 00:00:00
What is the return type of malloc() or calloc()

void *

void *

Pointer of allocated memory type

Pointer of allocated memory type

void **

void **

int *

int *

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 16

Time: 00:00:00
Consider the following three C functions :








[PI] int * g (void)  {    int x= 10;    return (&x);      [P2] int * g (void)  {    int * px;    *px= 10;    return px;  }     [P3] int *g (void)  {    int *px;    px = (int *) malloc (sizeof(int));    *px= 10;    return px;  }





Which of the above three functions are likely to cause problems with pointers?


Only P3

Only P3

Only P1 and P3

Only P1 and P3

Only P1 and P2

Only P1 and P2

P1, P2 and P3

P1, P2 and P3

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 17

Time: 00:00:00
Assume that the size of int is 4.











#include <stdio.h>

void f(char**);

int main()

{

    char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" };

    f(argv);

    return 0;

}

void f(char **p)

{

    char *t;

    t = (p += sizeof(int))[-1];

    printf("%sn", t);

}



ab

ab

cd

cd

eg

eg

gh

gh

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 18

Time: 00:00:00
Predict the output of below program:











#include <stdio.h>




int main()

{

    int arr[5];

    // Assume base address of arr is 2000 and size of integer is 32 bit

    printf("%u %u", arr + 1, &arr + 1);




    return 0;

}



2004 2020

2004 2020

2004 2004

2004 2004

2004 Garbage value

2004 Garbage value

The program fails to compile because Address-of operator cannot be used with array name

The program fails to compile because Address-of operator cannot be used with array name

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 19

Time: 00:00:00
Predict output of following program











int main()

{

    int i;

    int arr[5] = {1};

    for (i = 0; i < 5; i++)

        printf("%d ", arr[i]);

    return 0;

}



1 followed by four garbage values

1 followed by four garbage values

1 0 0 0 0

1 0 0 0 0

1 1 1 1 1

1 1 1 1 1

0 0 0 0 0

0 0 0 0 0

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 20

Time: 00:00:00
In C, what is the meaning of following function prototype with empty parameter list
void fun() {    /* .... */ }

Function can only be called without any parameter

Function can only be called without any parameter

Function can be called with any number of integer parameters.

Function can be called with any number of integer parameters.

Function can be called with one integer parameter.

Function can be called with one integer parameter.

Function can be called with any number of parameters of any types

Function can be called with any number of parameters of any types

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Get over 200+ Courses under One Subscription

mute

Don’t settle Learn from the Best with PrepInsta Prime Subscription

Learn from Top 1%

One Subscription, For Everything

The new cool way of learning and upskilling -

Limitless Learning

One Subscription access everything

Job Assistance

Get Access to PrepInsta Prime

Top Faculty

from FAANG/IITs/TOP MNC's

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.