type casting

Hello guys,any help you can provide will be appreciated......

Assume the following variable definitions:

int a = 5, b = 12;

double x = 3.4, z = 9.1;

What are the values of the following expressions?

a. b/a

b. x*a

c. static_cast<double>(b/a)

d. static_cast<double>(b)/a

e. b/static_cast<double>(a)

f. static_cast<double>(b)/static_cast<double>(a)

g. b/static_cast<int>(int)

h. static_cast<int>(x)*static_cast<int>(z)

i. static_cast(x*z)

j. static_cast<double>(static_cast<int>(x)*static_cast<int>(z))
This isn't a homework service. We're not going to do your homework for you.

If you have a specific question or need something clarified, we can help with that. But don't just post your assignment and ask us to solve it for you.
haven't you got a compiler??
You can have the answers in 5 minutes.
Am really sorry if am asking for too much.I dont want the work done for me,all I want is an idea about how to approah it.I missed the class and have no clue how to go about it.
tnx guestgulkan
I dont seem to know what the problem with this question is. Can someone help?

#include<iostream>
using namespace std;
int main()
{
int a = 5;
int b = 12;

double x = 3.4;
double z = 9.1;
cout<< "b/a";
return 0;
}
If you have access to a computer with a C++ compiler, why not use a program similar to the one above to print the values of all the expressions you're unsure about?
cout<< "b/a"; well "b/a" is a string isn't it and that is what will be printed on the screen.

what you want is something like:
cout<< "b/a is .... " << b/a << endl;
Topic archived. No new replies allowed.