Blog untuk berbagi ilmu komputer

Friday, October 24, 2014

Contoh Koding C++ Konversi Suhu

Contoh program sederhana dengan Turbo C++ untuk membuat program konversi suhu dari Celcius ke fahrenheit.





#include <iostream.h>
#include <conio.h>
#include <iomanip.h>

void main()
{
clrscr();
int no, celci;
no = 0;
float fahre;
cout<<"konversi nilai celcius to fahrenheit \n";
cout<<"+----------------------------+\n";
cout<<"| no | celcius | fahrenheit  |\n";
cout<<"+----+---------+-------------+\n";
celci = 0;
for(no=1;no<=10;no++)
{
cout<<"|"<<setw(4)<<no<<"|"<<setw(9)<<celci<<"|";
fahre = (1.8*celci)+32;
cout<<setw(13)<<fahre <<"|\n";
celci = celci + 10;
}
cout<<"+----+---------+-------------+\n";
}
Share:

0 comments:

Post a Comment

Blogger templates