Basics of c language for interview
Table of Contents
Learn basics of c language for interview MCQ Questions and Answers on Basics to attend job placement exams, interview questions, college viva and Lab Tests
Letus learn C Programming Basics in this multipart tutorial which are useful for students in the last minute before exam. C Programming Language was invented by Dennis Ritchie in Bell Laboratories. Now Nokia owns Bell Laboratories and experiments are still going on.
Basics of c language for interview
We shall learn about basic structure of a C Program and predefined Keywords in this C Programming Syntax Basics Tutorial Part 1. You can set up a Turbo C Compiler on your Windows Machine easily.
Structure of a C Program
Every C program contains a function or method called main(). All functions end with Round Brackets or Paranthesis ( ). Inside Paratheses, arguments can be received or passed. Code of a Function is surrounded by Curly Brackets or Braces { }.
#include <stdio.h> void main() { /*This is a multi-line comment. It is not compiled or checked for Syntax*/ printf("Hello C.."); }
Output
Hello C..
Observations
- VOID is a return type. VOID means nothing is being returned.
- main() { } is a compulsory function in any C Program.
- void and main should be typed in lowercase completely.
- / symbol is called Forward Slash or simply Slash.
- * symbol is called STAR.
- /* */ is a multiline comment. Comments are useful for analysing code logic flow in very big projects. Comments make others easily understand your program or project.
- printf() is a function which is passing one argument “Helllo C”.
- “Hello C” is a string literal here.
- Code statements or lines end with Semicolon ;
- Putting a return type before a function name is not mandatory in a C Compiler. If you use a C++ Compiler to compile c programs, you must specify a return type.
- #include includes an already written header file stdio.h which contains code for printf function. Without predefined functions, life becomes difficult to write everything every time on our own. Also the code without including files becomes clumsy to maintain and understand.
Keywords in C Language (Basics of c language for interview)
There are a total of 32 keywords in C Language which can not be used for the names of variables and functions. Find the C Programming Keyword list below. Students need to remember these keywords just like that to attempt questions asked in their exams.
Keyword | Meaning |
auto | Defines local life time for a variable |
break | Breaks a current loop in general |
case | Defines branch control point |
char | Basic data type, character literal |
const | Defines a Constant, unmodified variable |
continue | control goes to the loop beginning |
default | control point used in switch construct in general |
do | do while loop |
double | Floating point data type bigger than float type |
else | Usually followed by if construct. If conditon fails, branch to else block |
enum | Used to define a group of int constants like array |
extern | Used to define a variable or function with type and the definition may exist some where |
float | Floating point data type |
for | For Loop |
goto | Transfers execution control to defined Label |
if | A conditional statement |
int | Basic integer data type |
long | Integer data type bigger than int |
register | Tells to store the variable in RAM register |
return | ends execution immediately |
short | Type Modifier |
signed | Type Modifier |
sizeof | used to get the size of a variable. Eg. sizeof(integerType) |
static | used to create a variable with broad scope |
struct | Used to define a custom data type kind of thing |
switch | switch branch control |
typedef | used to create new type |
union | used in grouping of variables of same type |
unsigned | Modifiere used to increase positive max value |
void | empty data type or return type |
volatile | Used to create a variable with a value changed by any external process |
while | while loop with a condition |
[WpProQuiz 18]
Basics of c language for interview MCQ
1) Who invented C Language.?
A) Charles Babbage
B) Grahambel
C) Dennis Ritchie
D) Steve Jobs
Answer [=] C
Explanation:
Full name is Dennis MacAlistair Ritchie. He also invented Unix Operating System along with his colleague Ken Thomson.
2) C Language is a successor to which language.?
A) FORTRAN
B) D Language
C) BASIC
D) B Language
Answer [=] D
3) C is a which level language.?
A) Low Level
B) High Level
C) Low + High
D) None
Answer [=] B
Explanation:
C is a high level language. Another example is BASIC.
4) Low level language is .?
A) Human readable like language.
B) language with big program size.
C) language with small program size.
D) Difficult to understand and readability is questionable.
Answer [=] D
Explanation:
Looks like raw data often in the form of 1’s and 0’s.
5) High level language is a .?
A) Human readable like language.
B) language with small program size.
C) language with big program size.
D) language which is difficult to understand and not human readable.
Answer [=] A
Explanation:
Examples are C and BASIC.
6) Which program outputs “Hello World..” .?
A)
main() { scanf("Hello World.."); }
B)
main() { printf("Hello World.."); }
C)
main() { print("Hello World.."); }
D)
main() { scan("Hello World.."); }
Answer [=] B
7) C is _______ type of programming language.?
A) Object Oriented
B) Procedural
C) Bit level language
D) Functional
Answer [=] B
Explanation:
C is a procedural language. It is written in a number of steps using statements and functions. Logic is clearly depicted in the program. Procedural language is aslo called Imperative Language. Examples are COBAL, BASIC etc.
8) What is the present C Language Standard.?
A) C99 ISO/IEC 9899:1999
B) C11 ISO/IEC 9899:2011
C) C05 ISO/IEC 9899:2005
D) C10 ISO/IEC 9899:2010
Answer [=] B
9) What are the new features of C11 or ISO IEC 9899 2011 standard.?
A) Type generic Macros, Static Assertions
B) Multi Threading, Anonymous Unions, quick_exit
C) Bounds Checking Interfaces, Anonymous Strurctures
D) All
Answer [=] D
10) C language was invented in which laboratories.?
A) Uniliver Labs
B) IBM Labs
C) AT&T Bell Labs
D) Verizon Labs
Answer [=] C
Explanation:
C was invented in Bell Laboratories in New Jersey.
11) BCPL Language is also called..?
A) C Language
B) B Language
C) D Language
D) None
Answer [=] D
Explanation:
B language is successor of BCPL ( Basic Combned Programming Language ). B language was invented by Ken Thomson.
12) C language was invented to develop which Operating System.?
A) Android
B) Linux
C) Ubuntu
D) Unix
Answer [=] D
Explanation:
C was invented to develop Unix Operating System to overcome compatibility with different Hardware Platforms.
13) C language was invented in the year.?
A) 1999
B) 1978
C) 1972
D) 1990
Answer [=] C
14) C language is used in the development of .?
A) Databases
B) Graphic applications
C) Word Processors
D) All of the above
Answer [=] D
Explanation:
C language is very efficient in using hardware resources.
15) A C program is a combination of.?
A) Statements
B) Functions
C) Variables
D) All of the above
Answer [=] D