Hi!
I just started to learn C++ with this tutorial: http://newdata.box.sk/bx/c/index.htm
I am using CodeBlocks and it seems that the code in the tutorial is outdated or what? Why won't these programs work?
1 2 3 4 5 6 7 8 9 10
#include <iostream.h>
int main()
{
int x = 5;
int y = 7;
cout "\n";
cout << x + y << " " << x * y;
cout "\n";
return 0;
}
gives these errors: D:\c++\hello\Untitled1.c:1:22: error: iostream.h: No such file or directory
D:\c++\hello\Untitled1.c: In function 'main':
D:\c++\hello\Untitled1.c:6: error: 'cout' undeclared (first use in this function)
D:\c++\hello\Untitled1.c:6: error: (Each undeclared identifier is reported only once
D:\c++\hello\Untitled1.c:6: error: for each function it appears in.)
D:\c++\hello\Untitled1.c:6: error: expected ';' before string constant
D:\c++\hello\Untitled1.c:8: error: expected ';' before string constant
I only got that "iostream.h" should be just "iostream"
Thank you for help!
This tutorial is for Turbo c++ v3 which is outdated.
For code blocks refer this site tutorials.
For instant use
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
usingnamespace std;
int main()
{
int x = 5;
int y = 7;
cout<<"\n";
cout << x + y << " " << x * y;
cout "\n";
system("pause"); //for holding screen
return 0;
}
Hi and Welcome.
If your using Code::Blocks I sugest you use the tutorials on this site http://www.cplusplus.com/doc/tutorial/ you will find that they are more compatible with the code::bocks compiler.
The tutorial you are using is for a Borland compiler.
anyway try and run this code code::blocks and note the mistakes in lines 1, 6 and 8. also ussing namespace std; should be in line 2.
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
usingnamespace std;
int main()
{
int x = 5;
int y = 7;
cout << "\n";
cout << x + y << " " << x * y;
cout << "\n";
return 0;
}