GE6151 – COMPUTER PROGRAMMING REG.2013 NOTES
Prepared by V.Balamurugan, Assistant professor / Dept of IT
UNIT – 2 ‘C’ Programming Basics
Part – A (2mark questions)
1. What are the advantages and disadvantages of
C language?
Advantages:-
Suitable for creating application software and
system software
Easy, simple and fast.
It can be used for general purpose
Powerful language
Flexible and portable
Disadvantages:-
It is a weakly typed language
It needs extra memory space
It is not object oriented language
2. What are the characteristics of C language?
It has many in-built functions
Pointers can be used
It is a structured language
Small and easy to understand
Efficient programming language
It can be used in many types of computers
3. Give the structure of a C program
Documentation section
Preprocessor section
Definition section
Global declaration section
Main function()
{
Declaration part;
Executable statements;
}
User defined function()
{
Executable statements;
}
4. What are the steps to execute a C program?
Create a C program
Compile the program (Alt+F9)
Link that program to library
Execute the program(Ctrl+F9)
5. What is a token? What are the types of Tokens?
The smallest individual unit of a program
is called as Token
Identifiers, keywords, constants, strings,
operators
6. Mention some keywords in C language
If, else, while, do, for, continue, break, include,
main, int, float, char, void
7. What is a constant?
A constant is a fixed value that cannot be changed
in the C program execution.
8. What is a variable?
A variable is an identifier for memory
location
Data can be stored in it and taken when
needed.
9. What is user-defined datatype? What are its types?
User can define a new kind of datatype to declare
variables. It is called as user-defined datatype
Types: Typedef, Enumerated
10. What is the difference between local variable and
global variable?
LOCAL VARIABLE GLOBAL VARIABLE
Defined at starting of a
block
Declared before the main
function
It can be used only within
that block
It can be used anywhere in
the program
ex:-
int a=10;
void main()
{
printf(“%d”,i);
}
o/p:- 10
ex:-
void main()
{
int i=10;
printf(“%d”,i);
}
o/p:- 10
11. What ate the data types available in C?
In-built data type (int, char, float, …)
User defined data type( typedef, enum,struct)
Derived data type (array, pointer, function)
No data type (void)
12. What are the basic (or) fundamental datatypes?
Int – to store numbers without decimal point
Float – to store numbers with decimal point
Char – to store a single character
Double – To store a big decimal point number
13. Write any 6 escape sequences in C.
\n – move to next line
\t – move one space horizontally
\v- move in space vertically
\f – move to next page
\r – move to starting of that line
\b – backspace
14. What is an operator? What are its types?
An operator is a symbol that tells computer to
perform certain task.
Types:-
Arithmetic operators (+, -, *, /, % )
Relational operators ( <, >, <=, >=, ==, != )
Logical operator ( &&, ||, !)
Assignment operator ( +=, -=, *=, /=, %=, = )
Increment/decrement operator (i++, ++i, i--, --i)
Conditional operator ( ? : )
Bitwise operator ( &, |, ^, <<, >>, ~)
Special operator ( sizeof() )