Home » » Conditional operator in C++ Programming

Conditional operator in C++ Programming

Conditional operator in C++ Programming

Conditional operator in C++ Programming

Conditional operator or ternary operator

Symbol - ?

 #include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
cout<<"Enter the value of a and b is:"<<endl;
cin>>a>>b;
c=a>b?a:b;
cout<<"The value of c is:"<<c<<endl;
getch();
}

While program

#include<iostream.h>
#include<conio.h>
void main()
{
int a;
clrscr();
cout<<"Enter the value of a is:"<<endl;
cin>>a;
while(a<=10)
{
cout<<"santhosh"<<endl;
a++;
}
getch();
}

Do while program

#include<iostream.h>
#include<conio.h>
void main()
{
int a;
clrscr();
cout<<"Enter the value of a is:"<<endl;
cin>>a;
do
{
cout<<"santhosh"<<endl;
a++;
}
while(a<=10);
getch();
}

For program

#include<iostream.h>
#include<conio.h>
void main()
{
int i,n;
clrscr();
cout<<"Enter the value of n is:"<<endl;
cin>>n;
for(i=1;i<=n;i++)
{
cout<<"santhosh"<<endl;
}
getch();
}


0 coment�rios:

Post a Comment

Link you don't want to vouch for Read more: https://html.com/seo/#ixzz5zVltiZ5g