i have problem in this question. can everyone help me to create this question using c++.
a program that create a table of competition running distances in meters, kilometers, yards and miles. distances should be used : 100m, 200m, 400m, 800m. use the pattern exhibited in these distances to write program . ( Note : 1m= 0.001km= 1.094yd= 0.0006215mi)
Input specifications : No external input ( meaning no data input from the keyboard or file). All distances are real numbers.
Output specifications : Print the result to the screen in the following manner :
Table of Olympic running distances
Meters Kilometers Yards Miles
100
200
400
800
Edit/Delete Message
I have problem in this question. can everyone help me to create this question using c++.?
/*
I assume you are writing this for a console, and not for a visual c++ type program. This is c++ from before the c++ standard arrived in the late 90s. It will execute perfectly under the Borland Turbo C++ compiler. If you are using a newer compiler, I suggest you replace the first line with the following two:
#include %26lt;cstdio%26gt;
using namespace std;
Also, i used the old console functions, not the 'cin' and 'cout' classes. It should, however, still compile.
*/
#include %26lt;stdio.h%26gt;
void main(void) {
float distance[4] = { 100.0, 200.0, 400.0, 800.0 };
float conversion[4] = { 1.0, 0.001, 1.094, 0.0006215 };
int i, j; // counter variables
printf("Table of Olympic running distances\n");
printf("Meters\tKilometers\t"
"Yards\tMiles\n");
for (i = 0; i %26lt; 4; i++) {
for (j = 0; j %26lt; 4; j++) {
printf("%6.4f%c", distance[i] * conversion[i], (j == 3 ? '\n' : '\t'));
}
}
}
chelsea flower show
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment