HI

hi folks,

i am new here,i know some basics in c++.
i would like know answer for this question..?

1
2
3
4
5
6
7
8
#include<iostream.h>
#include<conio.h>
void main()
{
int a=(300*300)/300;
cout<<a;
getch();
}


OUTPUT
value of a is 81 (in c or c++ compiler )

CAN ANYBODY EXPLAIN WHY...?

edit : it must be borland c++/c complier ( old school , i guess..)
thanks for your replies though
Last edited on
After some adjustments it works for me:

http://ideone.com/Oj7wp

1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;
 
int main()
{
int a=(300*300)/300;
cout<<a;
 
}


I don;t know why yours returns 81 though.
Last edited on
pain sama wrote:
OUTPUT
value of a is 81 (in c or c++ compiler )

CAN ANYBODY EXPLAIN WHY...?
It shouldn't. The solution to the (300*300)/300 is 300, so either you've not copied the code across correctly or your compilers blonde (no offense :D ).

Be sure to check the code that your compiling is the same as you have provided above.
closed account (z05DSL3A)
See: http://www.cplusplus.com/forum/general/46696/

edit:
pain sama, please only post your question in one forum.
Last edited on
closed account (9wX36Up4)
#include<iostream>
#include<conio.h>

using std::cout;

main()
{
int a=(300*300)/300;
cout<<a;
getch();
}

I write this so u can examine it. u made two mistakes. and u can use int main() if u want both will work
1 - the library is not #include<iostream.h> it's #include<iostream>
2 - if u use cout cin or a code like that u should write before main() using std::examplecode; or using namespace std;for all codes
Last edited on
closed account (z05DSL3A)
His code is fine for the compiler he is using.
Topic archived. No new replies allowed.