include<iostream.h>

void main()

{

int i=o;
i=400*400/400;
cout<<i;

}

i am getting a wrong output

Recommended Answers

All 6 Replies

What output are you expecting? What are you getting? What is your thoughts on why they may not be the same?

i am getting a wrong output
This sentence tells us nothing, tell us WHAT output you have and how it is different from what you expected. THAT would provide us possibly more info to help solve your question.

The multiply and divide operators are of equal precidence for C/C++ compilers. What order they are evaluated it is up to the compiler. IE, your 400*400/400 expression can be evaluated as 400*(400/400) == 400, or (400*400)/400 == 400. Gee, they compute the same. If you aren't getting 400 as a result, then something else is going on!

int i=o;
That's not a number. It's the letter 'o'.

commented: Eye of an eagle! +15

I'm not so proficient in C and C++, but I guess such things as assigning a char to an int are still possible?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.