First off, I'd like to say hello to y'all, and thanks in advance for responding (assuming you do so in the first place).
I'm a beginning programmer (if even that), and was absolutely ecstatic when I used a free compiler (Bloodshed Dev-C++) to create my first "program". The purpose was originally to convert celsius to fahrenheit, and later to "count" to 10, to test the "while" function.
After compiling the program and initiating it, I input the number, hit enter....and it dissapeared. Closer investigation revealed the thing went freaking fast, finished, and decided it was done. With the loop "counter", it would zoom through anything less than 1000 and do the same thing.
I have the code I used for both of them at the bottom; can I "stagnate" the program so I can see the results, and, in the case of the "counting" program, can I slow it down abit? Thanks again.
And now, the code:
Code:
//
// Program to convert temperature from Celsius degree
// units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212 - 32)/100 + 32
//
#include <stdio.h>
#include <iostream.h>
int main(int nNumberofArgs, char* pszArgs[])
{
// enter the temperature in Celsius
int celsius;
cout << "Enter the temperature in Celsius:";
cin >> celsius;
// calculate conversion factor for Celsius
// to Fahrenheit
int factor;
factor = 212 - 32;
//use conversion factor to convert Celsius
// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32;
// output the results
cout << "Fahrenheit value is:";
cout << fahrenheit;
return 0;
}
And...
Code:
//WhileDemo - input a loop count. Loop while outputting astring arg number
// of times
#include <stdio.h>
#include <iostream.h>
int main(int arg, char* pszArgs[])
{
// input the loop count
int loopCount;
cout << "Enter loopCount: ";
cin >> loopCount;
while (loopCount > 0)
{
loopCount = loopCount - 1;
cout << "Only " << loopCount << " loops to go\n";
}
return 0;
}