|
Hi all,
i got question here need some information. i'm new in in programming.
could anyone help.
#include <stdio.h> <br />
int main()<br />
{<br />
int a,b,c:<br />
a=5;<br />
b=7;<br />
c=a+b;<br />
printf("%d+%d=%d\n",c,a,b);<br />
return 0;<br />
}</stdio.h>
Can, anyone help me go through with this. Thanks. in my mind, the answer display on the screen should be "12+5=17". i'm not sure is that correct. if not correct, can you please explain. Thanks all.
|
|
|
|
|
int a, b, c; <-- not ":", but ";"
the result is : 12+5=7
|
|
|
|
|
How about this? Do i do it correctly,
unsigned int a,b,c;
void main()
{
a=10;
b=7;
c=a>>5;
b=c|a;
a=~c&~b;
c=b*a^5;
}
end
I know >> is greater than. * is square and ^ xor.
The command like "|" and "~" i really not familiar with. Can anyone explain or go through with it. What it will be the final value for a, b and c? I really confused
|
|
|
|
|
Member 4099222 wrote: I know >> is greater than.
No, that's for shifting bits.
Member 4099222 wrote: * is square...
No, that's for multiplying.
Member 4099222 wrote: The command like "|"...
That is logical OR.
Member 4099222 wrote: and "~" i really not familiar with.
That is one's complement.
Member 4099222 wrote: What it will be the final value for a, b and c?
Why don't you try it and see?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Refer to your replied,
unsigned int a,b,c;
void main()
{
a=10;
b=7;
c=a>>5;
b=c|a;
a=~c&~b;
c=b*a^5;
}
end
The result i got for c=a>>5 is 0.3125 (because 10 divide with 32). So how do i proceed with b for 'or' operation and how to calculate the value of a? thanks
|
|
|
|
|
Member 4099222 wrote: So how do i proceed with b for 'or' operation...
The variable b will be assigned a value of 1 because either c or a will have a non-zero value.
Member 4099222 wrote: ...how to calculate the value of a?
I guess that would depend on what value you want it to have.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
unsigned int a,b,c;
void main()
{ a=10;
b=7;
c=a>>5;
b=c|a;
a=~c&~b;
c=b*a^5;
}
end
this is how is work on,
c=a>>5 ; //so c=10/32=0.3125
b=c|a; // so b=0.3125|10 = 1 (this one i'm not sure it right)
a=~c&~b; // so ~c= -0.3125 and ~b= 0. so ~c&~b=0 (& is AND operator)
c=b*a^5; // so b=1 and a^5=5 (^ is XOR operator)
so the final value for a,b and c
a=0 b=1 and c=5.
Please confirm that my work is right. Thanks for your help.
cheers
|
|
|
|
|
Member 4099222 wrote: Please confirm that my work is right.
Why? Can't you just print those values out to confirm?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
printf("%d+%d=%d\n",c,a,b);
c is your total and is in the wrong position.
b = 7 not 12 and is in the wrong position.
a is okay.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
How about this? Do i do it correctly,
unsigned int a,b,c;
void main()
{
a=10;
b=7;
c=a>>5;
b=c|a;
a=~c&~b;
c=b*a^5;
}
end
I know >> is greater than. * is square and ^ xor.
The command like "|" and "~" i really not familiar with. Can anyone explain or go through with it. What it will be the final value for a, b and c? I really confused
|
|
|
|
|
Member 4099222 wrote: c=a>>5;b=c|a; a=~c&~b; c=b*a^5;
WTF are you trying to achieve with this ?
why don't you just listen to the answers you get, try to understand them, and fix your code the simple way people just told you ?
your parameters to printf() are in the wrong order dude !
your code is making the addition of c = a + b , but you want to print c + b = a ... WTF !
what you do (the wrong thing):
printf("%d+%d=%d\n", c, a, b);
what you should do (the good thing):
printf("%d+%d=%d\n", <code>a, b, c</code>);
|
|
|
|
|
Hi,
I wanted to save HDC into a file(*.jpg). How can I do this?
I will appreciate your reply.
Thanks.
|
|
|
|
|
I'm quite new in this stuff and wonder how can I send a file to an eMail address ...
Maybe It's a funny question, but I should go ahead!
Thank you masters!
|
|
|
|
|
|
Hi masters!
--------------
Whenever I try to find drive types and their letters using GetDriveType(), FindFirstVolume() and also FindNextVolume(), I get an odd string like this:
//?/a12c-abb14d-acbb0252-dda525/
as the name of founded drives ...
How can I find drive types and letters (Something like: D:\, C:\, ...) on a given system?
Thank you masters!
modified on Tuesday, September 23, 2008 4:00 PM
|
|
|
|
|
To list the available volumes, use GetLogicalDriveStrings()[^]. Then, for each drive path returned, then use GetDriveType().
Regards,
--Perspx
"I've got my kids brainwashed: You don't use Google, and you don't use an iPod." - Steve Ballmer
"Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen an angry penguin charging at them in excess of 100mph." - Linus Torvalds
|
|
|
|
|
Thank you so much
Thank you masters!
|
|
|
|
|
Jusef Marzbany wrote: How can I find drive types and letters (Something like: D:\, C:\, ...) on a given system?
See here.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thank you very much
Thank you masters!
|
|
|
|
|
Hi masters!
--------------
Say we wanna call SetTimer(); As you know (or had better to know ), one of Its parameters is pointer to a function to be called after a certain time is elapsed (that's a call-back function).
how can I define a member function to pass to it?
I tried the following methods, but I got an/some error/s in both cases:
1- SetTimer( ..., &CMyclass::MemberFunction);
2- SetTimer( ..., Memberfunction);
unfortunatly I don't remember the exact error/s now and I'm not home to reffer to my project ...
I'm using VS 2005
Thanks in advanced ...
|
|
|
|
|
Jusef Marzbany wrote: how can I define a member function to pass to it?
By making it static .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
thank you
Thank you masters!
|
|
|
|
|
You can't, except if the function is a static function. Because member functions and non-member functions do not have the same prototype (for the member functions, there's an implicit 'this' parameter).
|
|
|
|
|
Thank you for your reply But I got another question:
You meant static functions doesn't have this within them?
Thank you masters!
|
|
|
|
|
Because they're class methods (instead of instance ones). Since a static method cannot access instance data, it does NOT need the this pointer.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|