Theoritical questions of c programming

Necessary fundamental knowledge before actual start of C Programming Language.

(1)List the five c compiler?
Ans:
Name Work on O.S Name of microprocessor
1. Turbo c M.S DOS 8086
2. Ansic c LINUX/UNIX 80386
3. Borland c WINDOW 80386
4. Microsoft c M.S DOS 8086
5. Visual c++ WINDOW 80386
Note:- 8086 is 16 bit microprocessor while 80386 is 32 bit microprocessor.


(2) Describe turbo c compiler?
Ans:
Turbo c compiler is one of the most popular c compiler.It is based on DOS operating system.It uses 8086 microprocessor which is 16 bit microprocessor. It has 20 address buses
and 16 data bus. It’s word length is two byte.
(3) What is hexadecimal number system ?
Ans:
In hexadecimal number system we use 16 differen digit so it’s base is 16
TABLE

Hexadecimal digit decimal equivalent binary equivalent
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111
To convert the binary number into hexadecimal number:
Make the group of four binary digit from right to left put the equivalent hexadecimal digit using TABLE.
e.g binary number =11000111110101
group of four digit from right 11 0001 1111 0101
to make group of four digit of left most digit 11,add two zero to the leftt side i.e 0011
now put the eqivalent hexadecimal digit form table
0011 0001 1111 0101
3 1 F 5
So,equivalent hexadecimal number will be 31F5
(4) What will address range which can repersent in 20 bit ?
Ans:
in binary in hexadecimal

Minimum possible number 0000 0000 0000 0000 0000 0000
Maximum possible number 1111 1111 1111 1111 1111 FFFF
In c any hexadecimal number statr with 0x 0r 0X
So,address range will be 0x0000 to 0xFFFF
It is 1MB memory range.
Note.
2^10 = 1KB
2^20 = 1MB
2^30 = 1GB
Where 10,20,30 are number of bit.
(5)What is difference betweent TSR and TSO program?
Ans :-
TSO means terminate but stay outside.It is those program, which release the main memory after the executon of the program.e.g Vcd cutter, turbo c compiler.
TSR means terminate but stay residence .It is those program, which after the execution of the program does not release the RAM (main memory).e.g antivirus.
(1) Why there are so many c compilers?
Ans:
(3)How many keywords are in c?
Ans:
43
(6)What is difference between .com program and .exe program?
Ans:
Both .com and .exe program are executable program but .com program execute faster than .exe program.All driver are .com program.
(2) How many type of error in c.
Ans:
183


Memory orgnization
To be a good programmer is very necessay to understand the memory structure.

(1) What is memory cell?
Ans:



Entire RAM has divided in number of equal part, which is known as memory cell.Capcity of each cell is to store one-byte data.
i.e char a resevre one memory cell while float a reseve four memory cell.
Each memory cell has unique addresss.Address are always in whole number an incresing order.

(6) What is residence memory?
Ans:





RAM has divided into two parts:
(1) Extended memory (useless)
(2) Residence memory :
When any program is excuted it is stored in the residence memory .For turbo c, it has 1MB residence memory i.e when we open turbo c it store 1MB in the RAM.
(3) What is physical address ?
Ans:
20 bit address of the memory cell is known as physical address or real address.In 20 bit we can repersent address from 0x00000 to 0xFFFFF.






(4) What is segmentation?
Ans:

Residential memory of RAM of size 1MB has divided into 16 equal part.These part is called segment.Each segment has size is 64KB.
1MB=16*64KB
This process of division is known as segmentation.
(5) What is necesity of segmentation?
Ans:
Physical address are 20 bit.But we have no pointer of 20 bit.So pointer can not access whole residential address .So to solve this problem we have three different pointer and segmentation has done.
(6) What is offset address?
Ans:
Each segment has divided into two parts.
1. Segment no (4bit)
2. Offset address (16 bit)
Each segment has same offset address but different segment number.
Suppose physical address is 0x500F1
Then it’s segment number is 5 and offset address is 00F1.

(7) Write a program to find the offset address of any variable?
Ans:
Void main ()
{
int x;
scanf(“%d”,&x);
printf(“%p”,x);
}
Note. %p is used to find the offset address (in hexadecimal) of any variable.

(8) What is data segment?
Ans:
Segment number 8 has special name which is known as data segment.
It has divided into four parts.


1. Stack area:-
All automatic variables are created into stack area.Default storage class of any local variable is auto.This variable may be int, char, float, array, pointer, struct, union etc.It also return fuction argument and return address.It follow LIFO datastructure. It has two part one for initialize variable another for non-initialize variable.All initialize variable are more nearer than unintialize variable and vice versa.

2. Data area :
All static and extern variable are created in the data area.
3. Heap area:
Malloc and calloc always allocate memory in the heap area.It is used for dynamic memory allocation.It’s size depends upon free space in the memory.
4. Code area:
Fuction pointer can only access code area.Size of this area is always fixed and it is read only area.



(10) What will output:
void main()
{
int a=5,b=6,c=7;
printf(“%d,%d,%d”);
}
Ans:
Output: 7 6 5
Explanation:
Default sotrage class int a=5 is auto.Since it automatic variable it will create in the stack area.
It will store in the stack as

Stack always follows LIFO datastructure.
In the printf statement name of variable is not written explicitly.So default output will content of
Stack which will be in the LIFO order i.e 7 6 5.
(9) what will be output:

void main()
{
int a=5 ,b,c=7;
printf(“%d %d %d”);
}
Ans:
Output: 7 5 garbage value
Explanation:
Automatic variable a and c has initialized while b has not initilize.Initialize variable are more nearer than non initialize variable .They will be stored in the stack.So due to LIFO first output will be 7 then 6 (since a is more nearer than b with respect to c) then any garbage value will be output which is persent in the stack.
(7) How many number system in c.
Ans:
There are three type of number system in c:
1. Decimal number e.g 25
2. Octal number e.g 025
3. Hexadecimal number e.g 0x25


(8) 010110 is which type of number in c?
Ans:
Octal integer constant (Since it starts with zero)
Note. C has not binary integer constant.


1 comment:

Unknown said...

really representation is in good form and useful information