Condition Statement
Condition Statement is similar to if-else statement but it is the short form of if-else .
Syntax :
(condition) ? statement1 : statement2 ;
Program to find whether the number is greater than 0 or not .
#include<iostream.h>
#include<conio.h>
void main(){
clrscr() ;
int numb ;
cout<<”\n Enter the number - ” ;
cin>>numb ;
( numb >0 ) ? ( cout<<” Positive number ” ) : (cout<<”Negative number ” ) ;
getch() ;
}
Program to find whether the number is divisible by 13 .
#include<iostream.h>
#include<conio.h>
void main(){
clrscr() ;
int numb ;
cout<<”\n Enter the number - ” ;
cin>>numb ;
( numb % 13 == 0 ) ? ( cout<<” Divisible ” ) : (cout<<” Not Divisible ” ) ;
getch() ;
}
Type Conversion and Type Casting
Type Conversion : The process of converting one predefined type into another is called Type Conversion. This type of conversion took place automatically .
Type Casting : The process of forceful conversion of one predefined type into another by user is called Type Casting. This type of conversion is forceful conversion .
For type casting , user have to mention the datatype into which the conversion should take place.
__________________________________________________________________________
0 comments:
Post a Comment
Please give your valuable suggestions