I've been using Visual Studio 2010 Ultimate to learn C++ and have created a project file. Within that project file are 2 .cpp files. I use one to refresh my memory of what I've learned and the other to enhance my knowledge of C++. The problem is that whenever I try to run my code, it returns nothing but "Press any key to continue..." in the command prompt. I have created the project as Win32 Console Application and haven't messed around with any of the settings; I think. Also, I press F5 to compile and run my code as I do not know where the "Compile and Run" option is in the interface. I am trying to run this code:

#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
	double a, b;
	int c = 0;

	for (a = 1.0; a == 100; a++) {
        b = a/17;
	cout << "If the Earth is " << a << " pounds, the Moon is " << b << "pounds./n";


	if (c == 25) {
		cout << "/n";
		c = 0;

	system ("PAUSE");
	return 0;

When I press F5, it returns nothing but "Press any key to continue...". I thought that maybe I had typed the code wrong so I wrote a very simple "Hello World" code, that also returned "Press any key to continue..." in the command prompt.

Please help!

Edited by __avd: Added [code] tags. Do wrap your programming code blocks within [code] ... [/code] tags

7 Years
Discussion Span
Last Post by myk45
a == 100;

This condition is not satisfied in the first iteration. So, the loop is terminated.

outside, c = 1

(c == 25)

So, even this condition is not met.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.