How to implement IF statement in C++
Rate this article
0 out of 5

In this tutorial we will show you how to implement IF statement in C++. After viewing the video tutorial, download the source code and try to modify the code so as to get a feel of what is learned in this video tutorial.




Program
#include<iostream.h>
#include<conio.h>
int main()
{
int n;
cout<<"Enter a number b/w 1 to 7 ";
cin>>n;
    if(n==1)
    {
                cout<<" Sunday";
    }
    else if(n==2)
    {
                cout<<" monday";
    }
    else if(n==3)
    {
                 cout<<" tuesday";
    }
    else if(n==4)
    {
                cout<<" wednesday";
    }
    else if(n==5)
    {
                 cout<<" thursday";
    }
    else if(n==6)
    {
                 cout<<" friday";
    }
    else if(n==7)
    {
                  cout<<" saturday";
    }
    else
                  cout<<"inavlid";
getch();
return 0;
}



Source Code


About The Author
TekTips Videos

Number Of articles Posted
27
Number Of Messages Posted
0
Joined Date
04/02/2013
   
Author
Messages
Posted:
Post Your Comments
Name (Max 50 Chars)
Comments

 
   
TekTipsDownload
GateExam
Academic Projects
TekTipsExperts
Android