C programming statements

Commonly statement is a line of code in c programming but statement also some types

1.simple statement:

     Simple statements don't have any condition and also they ends with semicolon (;). Like printf and scanf statements

Example--
  1. printf("c programming learning");
  2. scanf("%d",&a);
 
The above two can we called as simple statements. 

2. Conditional or control statement:

  These are having condition in the line. It may contain some block of code, if the condition is true then only inside block will execute otherwise won't execute.
  That's why for these statement we don't put semicolon at the end of the statement

 Examples-----

 1.if(a<2)
   {
      Printf ("SSCprogramming");
  }
   If and only if the a value must be less than 2 then only this will execute otherwise not execute.
 That's why we have to care about condition, what we are using in the code.
This will execute only single time. That's why this is not looping.

2. If(condition)//conditional statement
     Simple statements
   else
     Simple statements
  The above code is for execution of code in both the cases,  if the if condition is false then else part will execute.
 3.while(condition)
 In this the condition is true it continuesly execute untill we get false over there
That's why this is looping.



3. Complex statements:


 In this we can use both simple as well as condition or control statements, that's why we call it as complex statements.

Examples-----
if(printf("SS"))
  i++;

In this if consist of printf statement as well as condition.
NOTE: we all know that printf returns integer values , those are how many letters of numbers printing by printf statement
......



That's all about statements .......

Comments

Popular posts from this blog

strings in c programming

Header files in c

C programming basics