c++

#include <iostream>

int cout, main ();

{

cout << "hello , this is my" << endl;
return 0;

}
// what is the error in this
int cout, main ();
Remove 'cout,' and the semicolon

'cout' is under the std namespace. You have to do std::cout << /*...*/ << std::endl;
Last edited on
#include <iostream>
int main(void), i
using namespace std
{
for (int i = 0; i < 10; i+=3);
std::cout << "How often: " << i << ;

int i = 0;
while (i < 10)
{ std::cout << i << endl;
i += 4;}
} \\what is the error in this
Try this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "stdafx.h"

#include <iostream>

using namespace std;
int main(void)
{
int i = 0;
for (i = 0; i < 10; i+=3);
std::cout << "How often: " << i <<"\n";

i = 0;
while (i < 10)
{
	cout<< i << endl;
	i += 4;
}
} 
@warkari: you forgot the "{}" of the forloop and remove the ";" at the end of it


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>

int main()
{
	for (int i = 0; i < 10; i+=3)
	{
		std::cout << "How often: " << i << std::endl;
	}

	int i = 0;
	while (i < 10)
	{ 
		std::cout << i << std::endl;
		i += 4;
	}
}
Parentheses are not necessary for single-instruction statements, but that's more of a stylistic choice
@ maeriden: if you remove the ";" that's the case. otherwise you just print i=12
@Darkmaster

yeah i missed that point, thanks...
Topic archived. No new replies allowed.