Search Placementyogi.com
 

C Typedef & Enumerations Objective Questions

  :: Topics ::

1

Are the types of x and y in following program is same?

typedef int myint;
int x;
myint y;
A. Yes
B. No
See Answer & Explanation Lets Discuss
Correct answer is : A
Explanation
C programming language provides a keyword called typedef which you can use to give a type a new name. 
In above question myint is the new name of int type. Now we you use myint in place of int, both are same.
 
2

What is the output of the following programs?

//Program 1
#include<stdio.h>
#define int char      // Line 2
int main()
{
 int* str="Hello";    // Line 5
 printf("%s",str);
 
 return 0;
}
//Program 2
#include<stdio.h>
typedef int char;       // Line 2
int main()
{
 int* str="Hello";    // Line 5
 printf("%s",str);
 
 return 0;
}
A.

Program 1: Hello, Program 2: Hello

B.

Program 1: Compilation Error, Program 2: Hello

C.

Program 1: Hello, Program 2: Compilation Error

D.

Program 1: Compilation Error, Program 2: Compilation Error

See Answer & Explanation Lets Discuss
Correct answer is : C
Explanation

In Program 1 preprocessing is done before compilation so each occurrences of int is replaced by char and No Error during compilation!!

But program 2 throws error because int char together at line 2 are syntax error for compiler.

 
3

What is the output of the following program?

#include<stdio.h>
int main()
{
  enum {one,two,four=4,three=3,five=5,six,seven};
  printf("%d,%d,%d,%d,%d,%d,%d",one,two,three,four,five,six,seven);
}
A.

1,2,3,4,5,6,7

B.

1,2,4,3,5,6,7

C.

0,1,4,3,5,6,7

D.

0,1,3,4,5,6,7

See Answer & Explanation Lets Discuss
Correct answer is : D
Explanation

An Enum is a value type and its default value is 0 if not initialized explicitly.

 
4

What is the output of the following program?

#include<stdio.h>
int main()
{
   enum color{red,green,blue};
   typedef enum color mycolor;
   mycolor m=blue;
   printf("%d",m);
}
A.

0

B.

1

C.

2

D.

blue

See Answer & Explanation Lets Discuss
Correct answer is : C
Explanation

No explanation available. Let's Discuss

 
 

Banner to LogicGuns.com

Hide Page Information

C Typedef & Enumerations Objective Questions and Answers for Written Round Interview

Here you can find C Typedef & Enumerations Objective Questions with answers and explanation. We have a vast collection of Objective Questions on Typedef & Enumerations in C that will help you a lot!

Why learn C Typedef & Enumerations?

Typedef & Enumerations are an integral part of C and many Objective Questions in the written round are asked from this topic.In this section you can learn and practice C Typedef & Enumerations (Objective Questions with Answers) to improve your skills in order to face the interview and clear campus and off-campus selection of TCS, Infosys, Wipro etc.

Where can I get C Typedef & Enumerations Objective Questions and Answers with Explanation?

PlacementYogi provides you lots of fully solved C Typedef & Enumerations Objective Questions and answers with explanation. Fully solved examples with detailed answer description, explanation are given and it would be easy to understand.Though we do not have pdf file for C Typedef & Enumerations, We have quiz Objective Questions with answers to help you test yourself..

\n

Where can I get C Typedef & Enumerations Interview Objective Questions and Answers (objective type, multiple choice)?

Here you can find objective type C Typedef & Enumerations Objective Questions and answers for interview and entrance examination.Multiple Answers and true or false type Objective Questions are also provided.

How to solve C Typedef & Enumerations problems?

You can easily solve all kind of Objective Questions based on C Typedef & Enumerations by practicing the exercises (including shortcut Typedef & Enumerations to solve problems) given below.