Tutorials  Articles  Notifications  Login  Signup

Introduction C Programming variables (Set 1) C Programming variables (Set 2) C Programming variable and function declaration (set 3) Pointers in C Pointers (set 2)



C Programming variables (Set 2)



MCQ problems on C Programming variables declarations and initializations.


1.

Which is correct syntax to get remainder after dividing 3.14 by 2.1 ?

A.

remainder = 3.14 % 2.1;

B.

remainder = modf(3.14, 2.1);

C.

remainder = fmod(3.14, 2.1);

D.

Remainder cannot be obtained in floating point division.



2.

Types of linkage in C:

A.

Internal and External

B.

External, Internal and None

C.

External and None

D.

Internal



3.

Which special character is allowed in variable name ?

A.

* (asterisk)

B.

| (pipeline)

C.

 _ (underscore)

D.

- (hyphen)



4.

How are the following statements related ?

  1. extern int func();
  2. int func();

 

A.

Both are same

B.

Both are same but extern int func(); might be in another file

C.

int func(); will be override by extern int func();

D.

None of the options



5.

Which is correct way to round off 3.77 to 4.0 ?

A.

ceil(3.77)

B.

floor(3.77)

C.

roundup(3.77)

D.

roundto(3.77)



6.

Which is appropriate data type in C programming to represent real number ?

A.

float

B.

double

C.

long double

D.

long long double



7.

Identify the data type that are/is NOT user defined:

1. 

struct car
{
    char name[10];
    float price;
    int enginePower;
};

 

2.

long int x = 9.82;

 

3.

enum month {Jan, Feb, Mar, Apr};

 

A.

1

B.

2

C.

3

D.

1 and 2



8.

What can you say about following line of code:

extern int i;

 

A.

It is declaring variable i

B.

It is defining variable i

C.

It will throw error

D.

It's a function.



9.

Identify declaration statement(s):

1.

extern int m;

2. 

float cube( float x ) { ... }

3. 

double pow(double, double);

 

A.

1

B.

2

C.

1 and 3

D.

3



10.

Take a look at following piece of code:

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

 

What can you say about definition and declaration of variable ?

A.

extern int x is declaration, int x = 24 is the definition

B.

int x = 24 is declaration, extern int x is the definition

C.

int x = 24 is definition, x is not defined

D.

x is declared, x is not defined



11.

Prototype of a function is mentioned during ____

A.

Definition 

B.

Declaration

C.

Prototyping

D.

Call





HackerFriend Logo

Join the community of 1 Lakh+ Developers

Create a free account and get access to tutorials, jobs, hackathons, developer events and neatly written articles.


Create a free account