Step-by-step instructions on how to write and run a c++ program in microsoft visual studio to convert miles to kilometers. The code takes user input for miles and calculates the equivalent distance in kilometers using the conversion factor.
Download Converting Miles to Kilometers using C++ in Microsoft Visual Studio - Prof. Kai Qian and more Study notes Programming Languages in PDF only on Docsity!
Demo : Distance.cpp
Click “start” “programs” ”Microsoft Visual Studio 2005” ” Microsoft Visual Studio 2005”
Click “File” “New”” “Project”.
Select “Visual C++” and “Win32 Console Application” and Name the project as “Distance”. Click “OK” button.
Delete all the lines in the page displayed and enter the follow”ing lines of code. // distance.cpp #include<stdio.h> #include<stdafx.h> #include"conio.h" int main() { float kms , miles ; printf("\n Please Enter the Distance in miles to be converted to kms :"); scanf("%f" , & miles); kms = (miles* 8)/5; printf("\n The Equivalent distance in kms : %f" , kms ); getch(); return(0); }
Now” that w”e are done w”ith w”riting the code, Click “File” “Save Distance.cpp”.
Now” to compile the code click “Build” ” Build Distance”.
To Run the application click “Debug” “Start Debugging” as follow”s
Demo : Distance.cpp
Click “start” “programs” ”Microsoft Visual Studio .NET 2005” ” Microsoft Visual Studio .NET 2003”
Click “File” “New”” “Project”.
Select “Visual C++ Projects” and “Win32 Console Project” and Name the project as “Distance”. Click “OK” button.
Now” that w”e are done w”ith w”riting the code , Click “File” “Save Distance.cpp”.
Now” to compile the code click “Build” ” Build Distance”.
To Run the application click “Debug” “Start” as follow”s
In the opened w”indow” Enter any miles to be converted to miles and then press “enter” button.