Computer Concept & Programming In C - Unit II - 6

Q.7. Write short note on the following -
(a) Keywords (b) Constants (c) ASCII Code (d) getch ( )                      (AKTU. 2011 - 12)
Ans. (a)Keywords: - Keywords are special words which are predefined and convey a special meaning to a compiler. There are nearly 32 keywords in C language.
Keywords cannot be used as variables, function-name etc.
(b) Constants: - Constants are the storage variables whose content or value CANNOT be changed during the execution of a program.
(c) ASCII Code: - It stands for American Standard Code for information interchange with a unique and fixed integer that is assigned to a character just as a roll number is assigned to every name of a student.
(d) getch( ): - get character is a function available in header file <conio.h>. It listen to the keyboard untill user presses a key and the program stops for that much time. It is generally used at last of a function main ( ) to hold output screen.

Q.8. Write short note on the following with example in reference to C language (i) Entry and exit control loops (ii) Switch statement and if statement.         (AKTU. 2010 - 11)
Related Questions -
Q. Explain the entry control and exit control looping statements in C with syntax.                                                                              (AKTU. 2012 - 13)
Ans. (i) Entry and exit control loops: -
Entry control loops are those loops in which the condition associated with the loop is checked before a loop body is executed. For loop and while loop of C language are entry control loops because the condition is checked first i.e. at the begining. For detail see example programs of for loop and while loop.
Exit control loops are those loops in which the condition associated with the loop is checked after a loop body is executed. do-while loop of C language is an example of exit control loop because the condition is checked at last i.e. at the end. For detail see example programs of do-while loop.
 




The basic difference between an entry control loop and an exit control loop is that if the condition associated with a loop is false at the begining then any entry control loop does not execute but an exit control loop at least once.
This is the flow chart of an entry controlled loop. The condition is checked first and is false. The result is that the value of i is not printed. Now consider an exit control loop with the conditions exatly similar to the previous flow chart but the condition is checked at the last.

The above loop prints the value of i once, although the condition is false at the begining. 
The equivalent C code is shown at the right handside.
(ii) Switch statement and if statement: -
1. if statement - It is the simplest statement of C language to check condition. It can be used to create any advanced condition checking statement. It is often used with its complementry statement else. The syntax is given below
if (< condition >) 
 {  
    < action if condition is true>;
 }  
else 
 {
    < action if condition is false >;
 }
< condition > is any boolean condition which may be true or false. For detial refer to example program of if statement.
2. Switch statement - It is a statement of language C which helps a programmer to define all possible cases that may arise. It is used at places where at most one out of all given cases is true at a time. switch statement is used with keywords case, break and default
The syntax of switch case statement is given below.
switch (< choice >)
      {
case <choice 1>: