C Interview Question-Answers (21-30)

Ques 21 : What are Constants in C ?

In C, Constants is a quantity that does not change with the execution of the program, but remains same throughout the whole program execution e.g. 10, 19.75, “INDIA” etc. Constants may be numbers, characters or strings and are also known as literals.

Ques 22 : What are variables ?

Variable is a name given to memory locations where different constants are stored. As its name suggests, it may vary during the execution of the program. In a Language, types of variables that it supports depend upon the types of constants e.g. In the Statement,

Z = 3.2*X+5*Y+19

Ques 23 : What are Data Types?

Data Type is a finite set of values along with set of rules of different operations. Data is very important in terms of programming. And it is basically how data is stored and the different operations performed on that particular data.

Ques 24 : About Arrays in C.

Arrays is basically a collection of same data types. Arrays is group of same type of data elements that have been given a common name. In C, array are declared as follows:]

data_type variable_name[size];

Where data_type may be any of the basic data type like int, float or char variable_name is the name of the array and size is the number of elements in any array.

Ques 25 : Explain Structure in C.

Some times we require a data is terms of records. In array we take data of same type but in the form of record we must require a data type in which different types of data can be clubbed together i.e. int , float, and char. For this type of requirement we need a data type called a structure data type in which different types of data can be clubbed together.

C Language Q/A (21-30) PDF

Send download link to:

Ques 26 : Unions.

Union are also the derived data types almost same as that of structure. They are declared in the same way as structures. the only difference in that structures, each variable has the separate memory allocation for each element but in union variables use the same memory locations. The space in the memory taken by the union is equal to the length of the variable that has the maximum size.

Ques 27 : typedef in Brief.

typedef provides us a short and meaningful way to call a data type which we have already declared. e.g.

struct student
{
   char name;
   int roll_no;
   int marks;
};

Whenever we need to declare any student using above structure we have to use the following:

struct student S;

i.e. complete declaration is required. By by using typedef we can give a short name to any data type For this example we can use the following statements

typedef struct student std1; 
//Every time we require student, we can declare it as just
std1 S;

Ques 28 : Size Qualifiers in C.

Size qualifiers are used to alter the size of basic data type. The keywords long and short are two size qualifiers. For example:

long int i;

The size of int is normally 2 bytes ut, when long keyword is used, that variable will be 4 bytes and its range will be automatically increased. If the larger size of variable is not required then, short keyword can be used in similar manner as long keyword. It will be of 2 bytes. For example:

short int i;

Ques 29 : Explain Sign Qualifiers.

Sign qualifiers are used to specify whether a variable can hold only positive value or both values. Keywords signed and unsigned are used for sign qualifiers. For example:

unsigned int a;
//unsigned variable can hold zero and positive values only
C Language Q/A (21-30) PDF

Send download link to:

Ques 30 : Explain Enumerated Data Type.

The enum data type is used to create our own data type and give it the values that data type would take.

enum class
{
BCA, BSC, BA, BCOM
};
enum class S1, S2;

With this definition S1 or S2 can have all the valid values like BCA, BSC, BA, BCO etc. Anything like ‘S1 = PGDCA’ will give an error message since it is not in the list of enum class data type.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top