Input a single character and print a message
 I need help i want to input a single character and print a message "It is a vowel" if it is a vowel otherwise print message
"It is a constant". By using if-else structure and OR operator only?
 I need help i want to input a single character and print a message "It is a vowel" if it is a vowel otherwise print message
"It is a constant". By using if-else structure and OR operator only?
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;
int _tmain()
{
   char v;
   cout<<"Enter a character: ";
   cin>>v;
   if(v=='a'|| v=='e' || v=='i' || v=='o' || v=='u')
   {
       cout<<"It is vowel";
   }
   else
   {
       cout<<"It is constant";
   }
   getche();
}
Â
In C++ if-else is decision Operator. As in real life we have the option and in particular condition we do specific task. Same as IF-ELSE used in programming for taking decisions.
Syntax of if-else
Â
void main()
{
  if(condition)
  {
  // if condition is true pointer will run this part of the program
  }
 else
 {
  in false condition pointer will run this part.
 }
}
 your program
#include<iostream.h>
#include<conio.h>
void main()
{
 char ch;
 cout<<"Enter a character";
 cin>>ch;
 if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
 {
  cout<<"its a vowel";
 }
 else
 {
  cout<<"its a consonant";
 }
}
Here I have used OR operator in IF condition .by the use of OR(||) operator compiler run the true part of if condition if any of the given condition is true otherwise ELSE part would be run.
Â