0

include<iostream.h>

void main()

{

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

}

i am getting a wrong output

6
Contributors
6
Replies
29
Views
2 Years
Discussion Span
Last Post by NathanOliver
0

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

0

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.

0

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!

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.