program to Illustrate if

/* program : Illustration of if*/
#include<iostream.h>
void main()
{
    int no;
    cout<<"\nEnter a number : ";
    cin>>no;
    if(no<100)
        cout<<"\nThe number is less than 100!!!";
}

-----------------------------------------

/* program:   Test for divisibility*/
#include <iostream.h>
void main()
{ // reports if one input number is not divisible by another:
      int n, d;
      cout << "Enter two positive integers: ";
    cin >> n >> d;
    if (n%d)
    cout << n << " is not divisible by " << d << endl;
}

---------------------------------------------

/*Program:  Multiple statements within if*/
#include<iostream.h>
void main()
{
    int marks;
    cout<<"\nEnter Marks : ";
    cin>>marks;
    if(marks<40)
    {
        int lessmarks=40-marks;
        cout<<"\nSorry!!!!!you are failed";
        cout<<"\nYou should have got "<<lessmarks<<" more marks";
    }
}


0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|