-
Code translating
I'm following a tutorial on http://cboard.cprogramming.com/newth...read&forumid=4 and I come across a program, well code.
It is as follows:
Code:
include <stdio.h>
int main()
{
int a=5;
int b=6;
int result=a*b;
printf("%d * %d = %d\n", a, b, result);
return 0;
}
So in the tutorial it say that this program is for c not c++. Well its obvious 'cause they use print not cout to print on screen, so how would this look like if you were to converet this to c++?
Are there sertain things I need to delete or put in other plases?:)
-
It would look like this:
Code:
include <iostream>
int main()
{
int a=5;
int b=6;
int result=a*b;
cout << a << "*" << b << "=" << result << endl;
return 0;
}
-
Why not read a C++ tutorial, or simply take a look at some of the code on the C++ board. This is afterall the C board, and your question is about C++.
-
About 99.95% of valid C code is valid C++. Your program would compile as C++ as well.