Monday 23 January 2012

Statements in C



Definition:


Collection of Tokens are called statements and ends with semicolon(;). (or) It is a instruction to the computer to perform specific action.


Types of Statements:


1. Simple Statement or Expression Statement

2. Compound Statement or Block Statement

3. Control statement or Control structures or Branching Statements


1. Simple Statement or Expression Statement:


It follows any c valid expression and followed by semicolon.


Ex:
 int a;
 a=a+1;
 printf("Hello World\n");
 ;


2. Compound Statement or Block statement:


It is collection of statements enclosed in braces ({,}).


Example:


{

 printf(" I'm Rajendra\n");

 getch();

}


3. Branching Statements (Selective Structures)

Branching: the statement which transfers control from one statement to another statement breaking the normal sequence of execution is known as control statement.


Types of Control Structures
 
1. Conditional statements

     if statement
      if..else statement
      if...else if....else Statement
      switch statement

2. Unconditional statements or Jump Statements

       break
     continue
     go to


3. looping statements or repetative statements

   for loop
   while loop
   do-while

Review Questions in Statements

Short answers type
4) Differentiate for do while loops.
7) List any four important features of C language.
8) What is a null statement?
9) List the various conditional statements available in C.
10) What do you meant by conditional expressions?
11) Write a C program to find the whether the given year leap year or not.
12) Write a C program to print the following output: 
                      1
                      22
                      333
13) Explain the switch statement with syntax.
14) Write a C program to find the factorial of a given number.
15) Write the difference between it and else if statements.

                                                    Essay type questions
1) With the help of a flow chart explain the working of while loop.
2) With the help of a flow chart explain the working of do while loop.
3) Explain the working of for loop with the help of flow chart.
4) Explain how continue statements effect the looping.
5) Explain the comma operator with the help of a program.
6) List out the various conditional statements available in C and explain about them with the help of flow chart and a program.
7) Explain multiday conditional statements with the help of a program.
8) Explain the switch statements with the help of a floe chart.
9) With a C program to print whether inputted character is a vowel or not using switch statement.
10) Explain the following statements used in C
(a) if statement
(b)if….else statement
(c)while
(d)do….while.
11) Write a C program to print between 1 and 100.
12) (a)What is a conditional operator ? explain.
     (b)Write the syntax of Do…..while loop with sequence of operations.
13) Explain the working of nested for loop.
14) Write a program in C to calculate loop
    1+2+3…………100 using while loop




---------------------------------------------------------------------------------------------------------
(review questions)
1.       State the need for branching statements?
2.       What are the branching statements used in c?
3.       Write the syntax of various conditional statements available in ‘C’
4.       (i) define conditional statement and list the conditional statements used in ‘C’ language (ii) Explain the different branching statements available in C with examples. (or) List the various conditional statements in c and explain briefly with suitable examples. (or) Explain in detail different conditional statements with their flowcharts and examples
5.       Explain if..else statement with syntax and example
6.       (i) explain the following statements used in C. (a) if statement (b) if..else statement (ii) explain about syntax of (a) if—statement (b)if-else statement (c) nested-if-statement in C.
7.       (i) explain if..else statement with a flowchart. (ii) write the syntax for  if—else statement in C with an example.
8.       Describe different forms of if statement in c
9.       Explain nested if--.else statement in c.
10.    Write the differences between if and else ..if statements
11.    Give the general form of a switch statement and describe how the switch statement is executed (0r) explain the switch statement in c with syntax
12.    Explain in what way does a switch statement differs from an if statement.
13.    Give the syntax of the switch statement with an example.
14.    Explain the switch statement with the help of a flowchart and a suitable c program
15.    write a program to find the average, grade of the 3 subjects using switch case



You may like the following posts:

C Tokens

                                   

No comments:

Post a Comment