C Language Interview Questions-1

C Language Interview Questions-1

Questions on C Language Introduction and Data Types:

1.) What is C Language?

•    The C programming language is a standardized programming language.
•    It was developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating system.
•    It has since spread to many other operating systems, and is one of the most widely used programming languages.
•    C is prized for its efficiency, and is the most popular programming language for writing system software, though it is also used for writing applications.

2.) What is a Programming language?

•    Programming language is any language that computer system can understand directly or indirectly to can perform the actions asked by the programmer as set of instructions in form of a computer program.
•    A program is written as a series of human understandable computer instructions.
•    The instructions can be read by a compiler and linker and translated into machine code so that a computer can understand and run it.

3.) What is history of C Language?

•    C is a programming language which born at “AT & T’s Bell Laboratories” of USA in 1972.
•    It was written by “Dennis Ritchie”.
•    This language was created for a specific purpose that is to design UNIX operating system which is used on many computers.
•    From the beginning C was intended to be useful to allow busy programmers to get things done because C is such a powerful, dominant and supple language, its use quickly spread beyond Bell Labs in the late 70’s.

4.) What is the purpose of C language?

•    In C one can write programs like that of high level languages as in COBOL, BASIC, FORTRAN etc. as well as it permits very close interaction with the inner workings of the computer.
•    It is a general purpose programming language. It is usually called system programming language but equally suited to writing a variety of applications.
•    It supports various data types
•    It follows the programming style based on fundamental control flow constructions for structured programming.
•    Functions may be pre–defined or user defined and they may return values of basic types, structures, unions or pointers.

5.) What type of language is C?

•    C is a general purpose, structured programming language.
•    Its instructions consist of terms that resemble algebraic expressions, augmented by English Keywords such as if, else, for, do and while.
•    In this respect C resembles other high-level structured programming languages such as Pascal and FORTRAN.
•    C also contains certain additional features that allow it to be used at a lower level thus bridging the gap between machine language and the more conventional high-level languages.
•    This flexibility allows C to be used for systems programming (E.g.: writing operating systems) as well as for applications programming.

6.) Why C is called Middle level language?

Middle Level programming languages are closely related to Machine as well as Human being.
•    C programming supports Inline Assembly Language programs.
•    Using inline assembly language feature in C we can directly access system registers.
•    C programming is used to access memory directly using pointer.
•    C programming also supports high level language features.
•    It is more User friendly as compare to previous languages so C programming is Middle level language.

7.) Is C Language Case Sensitive Language?

Yes … in capital letter and lower letter have different meaning in c language. So C language is a case sensitive language.

8.) What are the advantages of C language?

•    Easy to write
•    Rich set of operators and functions that are built–in
•    Support for bit–wise operation
•    Flexible use of pointers
•    Direct control over the hardware
•    Ability to access BIOS/DOS routines
•    Interacting using Interrupts
•    Ability to write TSR programs
•    Ability to create .COM files
•    Ability to create library files (.LIB)
•    Ability to write interface programs
•    Incorporating assembly language in C program.

9.) What are the disadvantages of C language?

•    There is no runtime checking.
•    There is no strict type checking (for ex: we can pass an integer value for the floating data type).
•    As the program extends it is very difficult to fix the bugs.

10.) What are the steps of executing a C Program?

The steps involved in executing a C Program are:
•    Creating and Editing
•    Compiling
•    Linking   
•    Executing program

Creating and Editing: Writing or creating and editing a source program is a first step in c language. Source code is written in c programming language according to the type of problem or requirement, in any text editor.

Compiling: Computer does not understand c programming language. It understands only 0 and 1 means machine language. So c programming language code is converted into machine language. The process of converting source code in to machine code is called compiling.

Linking: There are many built in library functions available in c programming language. These functions are stored in different header files.

Executing program: Execution is the last step. In this step program starts execution. Its instructions start working and output of the program display on the screen.

11.) What is a compiler?

•    A computer program which reads source code and outputs assembly code or executable code is called a compiler.
•    A piece of software that takes third-generation language code and translates it into a specific assembly code, compilers can be a quite complicated piece of software.

Example: C Compiler.

12.) What is an interpreter?

•    In computing, an interpreter is a computer program that reads the source code of another computer program and executes that program.
•    Because it is interpreted line by line, it is a much slower way of running a program than one that has been compiled.
•    But is easier for learners because the program can be stopped, modified and rerun without time-consuming compiles.

Example: BASIC.

13.) Differences between Source code & Object code?

Source code:
Source code is in the form of a Text and is Human Readable. Source code is generated by Human and it is input given to the compiler.

Object code:
Object code is in the form of Binary numbers and it is in Machine Readable format. Object code is generated by the Compiler and it is the output of the Compiler.

14.) What is a Data Type?

A Data Type is a Type of Data. Data Type is a Data Storage Format that can contain a Specific Type or Range of Values.

When computer programs store data in variables, each variable must be assigned a specific data type.
Many people believe that a programmer working in C language is provided with a very tiny set of data types but Dennis Ritchie has made available to the C programmers a feature that allows them to derive their own data types from the existing one. This way a programmer can decide which data type is to be used depending on these 2 factors:

•    Economize the memory space.
•    Improve the speed of execution of program.

15.) List the different Data Types in C programming language?

In C language, it is compulsory to declare variables with their data type before using them in any statement. Mainly data types are categorized into 3 categories:

•    Primitive Data Types
•    Derived Data Types
•    User Defined Data Types

16.) What are the Primitive Data Types in C language?

The primitive data types in c language are the inbuilt data types provided by the c language itself. Thus, all c compilers provide support for these data types. The different primitive data types are,

17.) Define integer data type?

Integer data type is used to store numeric values without any decimal point e.g. 7,-101, 107, etc. A variable declared as 'int' must contain whole numbers e.g. age is always in number. Integer occupies 2 bytes memory space and its value range limited to -32768 to +32767.

18.) Define Floating point data type?

floating point data type consists of 2 types. They are,
•    float
•    double

float:float data type is used to store numeric values with decimal point. In other words, float data type is used to store real values, e.g. 3.14, 7.67 etc. A variable declared as float must contain decimal values e.g. percentage, price, pi, area etc. may contain real values. Storage size of float data type is 4. This also varies depend upon the processor in the CPU as “int” data type. We can use up-to 6 digits after decimal using float data type.The range for float data type is fromIE-38 to IE+38.

double: double data type also declares variable that can store floating point numbers but gives precision double than that provided by float data type. Thus, double data type is also referred to as double precision data type.Double data type is also same as float data type which allows up-to 10 digits after decimal. The range for double data type is from 1E–37 to 1E+37.

19.) Define character data type?

char (Character) data type is used to store single character, within single quotes e.g. 'a', 'z','e' etc. A variable declared as 'char' can store only single character e.g. Yes or No choice requires only 'y' or 'n' as an answer.

20.) Define void data type?

The void type basically means "nothing". A void type cannot hold any values. You cannot declare a variable to be a void, but you can declare a variable to be a pointer to a void. A pointer to a void is used when the pointer may point to various different types. To use the value that a void pointer is pointing to, it must be cast into another type.

21.) What are the user defined data types in C Language?

C Language supports a feature where user can define an identifier that characterizes an existing data type.This User defined data type identifier can later be used to declare variables. In short its purpose is to redefine the name of an existing data type. Different user defined data types are

22.) Define struct data type?

A struct is a user defined data type that stores multiple values of same or different data types under a single name. In memory, the entire structure variable is stored in sequence.

23.) Define union data type?

A union is a user defined data type that stores multiple values of same or different data types under a single name. In memory, union variables are stored in a common memory location.

24.) Define enumerated (enum) data type?

An enumeration is a data type similar to a struct or a union. Its members are constants that are written as variables, though they have signed integer values. These constant represent values that can be assigned to corresponding enumeration variables.

25.) Define typedef data type?

The 'typedef' allows the user to define new data-types that are equivalent to existing data types. Once a user defined data type has been established, then new variables, array, structures, etc. can be declared in terms of this new data type.

26.) What are the derived data types in C Language?

Derived data types are based on fundamental data types, i.e. a derived data types is represented in the memory as a fundamental data type.Derived data types don't create a new data type; instead, they add some functionality to the basic data types. Two derived data types are - Array & Pointer.


Post a Comment