convert this from c to c++ i will rate higher #include<stdio.h> #include <conio.
ID: 3608904 • Letter: C
Question
convert this from c to c++ i will rate higher #include<stdio.h>#include <conio.h>
int main ()
{
int Seats [ 10 ] = { 0 };
int Smoking = 0;
int Nonsmoking= 10;
int Input,assigned=0;
while(assigned<20)
{
printf("Please type 1 for "Smoking" " );
printf("Please type 2 for "Non-smoking" ");
scanf("%d", &Input);
if ( Input == 1 )
{if ( Smoking < 10 )
{Seats[Smoking]=1;
printf(" BOARDING PASS Your SMOKING seat is seat: %d ",Smoking+1);
Smoking++;
assigned++;
}
else
{
printf("The Smoking section is full. ");
printf("Next flight leaves in 3 hours. ");
}
}
else if(Input==2)
{if (Nonsmoking <20 )
{Seats[Nonsmoking]=1;
printf(" BOARDING PASS Your NON SMOKING seat is: %d ",Nonsmoking+1);
Nonsmoking++;
assigned++;
}
else
{printf("The Non Smoking section is full. ;");
printf("Next flight leaves in 3 hours. ");
}
}
}
getch();
return 0;
}
convert this from c to c++ i will rate higher #include<stdio.h>
#include <conio.h>
int main ()
{
int Seats [ 10 ] = { 0 };
int Smoking = 0;
int Nonsmoking= 10;
int Input,assigned=0;
while(assigned<20)
{
printf("Please type 1 for "Smoking" " );
printf("Please type 2 for "Non-smoking" ");
scanf("%d", &Input);
if ( Input == 1 )
{if ( Smoking < 10 )
{Seats[Smoking]=1;
printf(" BOARDING PASS Your SMOKING seat is seat: %d ",Smoking+1);
Smoking++;
assigned++;
}
else
{
printf("The Smoking section is full. ");
printf("Next flight leaves in 3 hours. ");
}
}
else if(Input==2)
{if (Nonsmoking <20 )
{Seats[Nonsmoking]=1;
printf(" BOARDING PASS Your NON SMOKING seat is: %d ",Nonsmoking+1);
Nonsmoking++;
assigned++;
}
else
{printf("The Non Smoking section is full. ;");
printf("Next flight leaves in 3 hours. ");
}
}
}
getch();
return 0;
}
Explanation / Answer
#include<iostream.h>
void main()
{
int seats[10]={0};
int smoking =0;
int nonsmoking = 10;
int input,assigned=0;
While(assigned < 20)
{
cout<<”please type 1 forSmoking”<<endl;
cout<<Please type 2 for Non-smoking“<<endl;
cin>>input;
if(input == 1)
{
if(smoking < 10)
{
seats[smoking]=1;
cout<<” boarding pass your smoking seat is seat%d ”<<smoking +1;
smoking++;
assigned++;
}
else
{
cout<<”the smoking section isfull”<<endl;
cout<<”next flight leaves in 3hours ”<<endl;
}
}
else if(input==2)
{
if(nonsmoking < 20)
{
seats[nonsmoking]=1;
cout<<” boarding pass m your non smoking seat is ”<<nonsmoking+1;
nonsmoking++;
assigned++;
}
else
{
cout<<”the non smoking section isfull”<<endl;
cout<<”next flight leaves in 3hours ”;
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.