Tuesday 15 April 2014

FEATURES OF C LANGUAGE PROGRAMMING

Relational Operators:

> 
Greater than
7 > 5
< 
Less than
5 < 7
>=
Greater than or equal to
6 >= 6
<=
Less than or equal to
5 <= 6
==
Equal to
8 == 8
!=
Not equal to
5 != 7


If condition:
If condition is used to put a condition, so that the program should proceed if the condition is satisfied.
Syntax:
if ( statement is TRUE )
      Execute this line of code
In this, if condition will first check if the condition is true or not, if it stands true it will execute the next line and if it’s not it will stop.

ELSE
Else is used to give other alternate if the “if” condition stands false, so there’s another statement to execute.
Syntax is:
if (TRUE) {
Execute these statements if TRUE
}
else {
Execute these statements if FALSE
}
Else if:
This function is used to run a loop using this command. This comprises of both functions “if” and “else” both.

For example:
#include <stdio.h>
int main()
{
    int age;
    printf( "Please enter your age" );
    scanf( "%d", &age );                
    if ( age < 100 ) {                
        printf ("You are pretty young!\n" );
    }
    else if ( age == 100 ) {          
        printf( "You are old\n" );      
    }
    else {
        printf( "You are really old\n" );    
    }
  return 0;

No comments:

Post a Comment