Write an expression that uses a conditional operator to set the value of discount to 10 if
price is less than 1500, and to 15 otherwise.
Answers
Your answer bro:
In C++ it will be:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float price;
cout<<"Enter price: ";
cin>>price;
if(price<15000
{
cout<<"\n The discount offered is 10%";
price = price - (0.1*price);
cout<<"\n Price= "<<price;
}
else
{
cout<<"\n The discount offered is 15%";
price = price - (price*0.15);
cout<<"\n Price= "<<price;
}
getch();
}
In C, it will be:
#include<stdio.h>
#include<conio.h>
void main()
{
float price;
clrscr();
printf("Enter the price: ");
scanf("%f", price);
if(price<15000
{
printf("\n The discount offered is 10%");
price = price - (0.1*price);
printf("\n Price= %f", price);
}
else
{
printf("\n The discount offered is 15%");
price = price - (price*0.15);
printf("\n Price= %f", price);
}
getch();
}
Please mark me brainliest