A gold smith sells a one gram of 24 carat gold for Rs 5500 .WAP to read the weight of gold in grams and calculate its cost in 18,20,22, and 24 carat in c++ ?
The weight of gold in grams and calculate its cost in 18,20,22, and 24 carat in c++.
#include<iostream.h>
#include<conio.h>
void main()
{
float weight,carat,carat18,carat20,carat22,carat24;
clrscr();
cout<<endl<<"Enter the weight of gold in grams :";
cin>>weight;
carat=5500/24.0;
carat18=carat*18*weight;
carat20=carat*20*weight;
carat22=carat*22*weight;
carat24=5500*weight;
cout<<endl<<"Cost in 18 carats = " <<carat18;
cout<<endl<<"Cost in 20 carats = " <<carat20;
cout<<endl<<"Cost in 22 carats = " <<carat22;
cout<<endl<<"Cost in 24 carats = " <<carat24;
getch();
}
#include<conio.h>
void main()
{
float weight,carat,carat18,carat20,carat22,carat24;
clrscr();
cout<<endl<<"Enter the weight of gold in grams :";
cin>>weight;
carat=5500/24.0;
carat18=carat*18*weight;
carat20=carat*20*weight;
carat22=carat*22*weight;
carat24=5500*weight;
cout<<endl<<"Cost in 18 carats = " <<carat18;
cout<<endl<<"Cost in 20 carats = " <<carat20;
cout<<endl<<"Cost in 22 carats = " <<carat22;
cout<<endl<<"Cost in 24 carats = " <<carat24;
getch();
}
Comments
Post a Comment