Chapter 4:
Input And Output
Programming Exercise
Problem # 4:
Write a program that inputs miles from the user and convert miles into kilometers. One mile is equal to 1.609 kilometer.
Solution:
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
float miles, kilometers;
cout<<"Enter miles :"<<endl;
cin>>miles;
kilometers = miles/1.609;
cout<<"Kilometers :"<<kilometers<<endl;
return 0;
}
#include<conio.h>
using namespace std;
int main()
{
float miles, kilometers;
cout<<"Enter miles :"<<endl;
cin>>miles;
kilometers = miles/1.609;
cout<<"Kilometers :"<<kilometers<<endl;
return 0;
}
Code Screenshot:
Output:
Let me know in the comment section if you have any question.
Previous Post:
3. Program to find out the area of triangle when three sides a, b and c of the triangle are given.
bhai yahan per miles*1.609 nae ho ga kya
ReplyDeleteNo. Because 1mile=1.609km, So 1km=mile/1.609
DeleteThanks Hadiqa.
Deletethanks and good work
ReplyDelete