Blog Moved

This website completely moved to new domain. For latest content, visit www.programmingposts.com

Search This Blog

10 Nov 2012

SIMPLE IF STATEMENT IN C

Syntax of Simple-if
-------------------------
if(condition)
{
 statement1;
 statement2;
 . 
 .
 .
 statement n;
}

Simple C Program to understand Simple if :


#include<stdio.h>
void main()
{
    int age;
    printf(" >>> c program to implement simple if<<< \n\n");
    printf("\n Enter the age of the person: ");
    scanf("%d",&age);
    if(age>=18)
    {
        printf("\n Eligible for voting \n");
    }
    printf("\n program ends \n\n");
}

Output:

Explanation:
In the above program, the control enters into the if block only if the condition is true. And the statement printf("\n program ends \n\n"); is executed every time.

1 comment:

  1. thank you for sharing useful info
    web programming tutorial
    welookups

    ReplyDelete