Any programmers in here who can help me with my program? I'm a noob BTW

Any programmers in here who can help me with my program? I'm a noob BTW.
>looking for c++ specifically but all are welcome
>pic not related

Other urls found in this thread:

cplusplus.com/reference/algorithm/max/
stackoverflow.com/questions/4772780/explain-this-snippet-which-finds-the-maximum-of-two-integers-without-using-if-el
techradar.com/news/software/best-free-data-recovery-tools-1321723
twitter.com/AnonBabble

C programmer here

So I have to write a program that includes overload functions "fmax(a,b) & fmax(a,b,c)" that will take in 3 numbers and print out the highest number but fmax(a b,c) cannot not use a conditional and that's the part I'm stuck on.

elaboreate on "cannot not use a conditional"

The max of a,b,c is the max of (a,b),c. If the max of a,b is a, then the max is the max of a,c. If the max of a,b is b, then the max is the max of b,c.

pretty easy: return fmax(a, fmax(b,c))

That's all the teacher said but I assume a conditional statement is what he meant

if you can't use conditional statement, use conditional expression: google for trenary

Being a pedant to the teacher isn't going to get him any points. If he can't use conditionals, he can't use ternaries either. Ternaries evaluate conditionals.

cplusplus.com/reference/algorithm/max/

I'm not unpacking this image. Last time I did this, I got arrested.

c, c++ and some other shit
cout

Can u elaborate a bit more, I understand what you're saying but how would my code look for fmax(a,b,c) exactly? As I used an if statement for fmax(a,b)

Let's break it down a bit more than I did initially. You have 3 variables: a, b,c.

int maxAB = fmax(a,b);

At this point you know that maxAB is either a or b, and it is the bigger of the two.

int maxABC = fmax(maxAB, c);

Because maxAB is the bigger of a and b, you can check just the two. If maxAB is bigger than c, it's the biggest. If c is bigger, it's the biggest.

return maxABC;

Make sense?

So bare with me, I'm using the same function for all 3 numbers instead of writing 2 functions?

Well you do need two functions. You said that's what the assignment is. fmax(int num1, int num2) is the first one. You said you already wrote that. Then fmax(int a, int b, int c) calls the first one like I showed.

This seems probable, even if you use the conditionals within fmax(a,b) there are none within fmax(a,b,c)

Okk thanks I get now

Are you sure you're allowed to use conditionals in fmax(a,b)?

Sweet. I accept pictures of your genitalia as thanks.

Yes just not for fmax(a,b,c)

I'm not sure there's any other way to do it. Only way I can think of would be to subtract and check for the sign of the return value, but that still requires a conditional (only in main instead of fmax).

Sure just post ur email address

You can do it with retarded bit manipulation and full understanding of how overflow works. I always forget how though because no one does that in real life.

Sure. appleciderrules at gmail

just post a pic of u dick fagget

Oh yeah, I guess I can see how you'd do it bit wise. Sort of. But that's still retarded.

Oh, OP, you could probably encase fucking everything in nested while loops, but that's completely retarded. But it would give you a conditional without actually using a conditional.

qq nothing so far

it's super retarded. It also wouldn't surprise me if it's actually how he's supposed to do it. I hate assignments like that. Let's learn to program by doing it incorrectly. Yay!

Kek just wait by tomorrow morning

I remember assignments like that.

return( (A > B)*A + (A < B) *B)

fucking scrubs. learn c

It's likely that he can't use any comparisons in the a,b,c function.

return ( (max(A,B) > C)*max(A,B) + (max(A,B) < C)*C )

You're using < in that too

why? they arent conditionals. logical statements

Yeah. Homework is stupid.

stackoverflow.com/questions/4772780/explain-this-snippet-which-finds-the-maximum-of-two-integers-without-using-if-el

C/C++/C#. I'm tired as balls and am not reading the rest of this thread. Sorry if this has already been said.

Using while loops and library methods are unreliable since you generally can't tell if they will use comparisons after compiled. Check out the method that this guy is asking for help with. You can make a method that compares the two numbers, call it for two numbers, then call it with the result and the third number.

Change up the code so you don't get a fire lit under your ass over it.

On the off chance that you're a DigiPen student, I send my sympathies.

so create a function without using logic or conditional statements? idk what that even means..

We've already covered the answer in this thread. What's not to get?

how is a while loop not a conditional?

yeah it wouldn't be allowed either

What you could do, and this is absolutely fucking idiotic and also dependent on what your compiler will let you get away with/what it does when you assign negative numbers to unsigned types, is call a function fmaxAB which subtracts B from A. Then return that value to an unsigned int. Then, if you create a while loop of while(unsigned int), in theory IF your compiler sets negatives to zero when assigned to an unsigned type/if your compiler will even compile if you do that, you could basically use the while loop while(unsigned int) as if(A > B). If that makes any sense at all. Basically a stupid little glitch of C that relies on the implicit conditionals of a while loop.

I highly doubt it would work on a "nice" compiler, or even a C++ compiler. A C99 compiler like Code Blocks would probably allow it though.

There's no rar in there anyhow. Or 7-/zip. That's pretty much the ones I could be arsed checking.

A conditional is implied, but it isn't explicitly present. I suppose the question then is how pedantic your prof is.

a condition is explicit in a while loop. while CONDITION is true, do something.

you can't even call one in C without the condition's arguments.

Learn Java and make real money.

Or C# and avoid becoming suicidal

Am not op but I also have a question in c++, if anyone is still here

Still lurkers, give it a shot.

Yup, my c++ is kinda bad though.

True, I suppose. Only way I could think to do the program without using an if statement at all though.

I don't know much C++, mostly C, but I can try.

Well I'm suppose to write a program in which I get the absolute value of a user inputted number, whether it's a int, double, float, or long, my program is suppose to "detect" that, what I want to kno is how it's suppose to detect that

>implying java programmers don't get payed in loads they have to swallow

>Or C# and avoid becoming suicidal
C# is a piece of shit under Microsoft control. Fuck that crap. Learn 84-bit, x86 assembly and really cash in.

How are you getting the number? cin, read from a file or what?

Are Ruby programmers still among the highest paid?

Get number
If( num < 0 )
{
Num = num + (-2 * num)
}
That would convert any negative number into absolute value. There's also a C library function I believe, and I'm sure there's a more efficient way, but that's off the top of my out of practice head.

Yeah I'm pretty sure cin is how were suppose to get the value

>Are Ruby programmers still among the highest paid?
Actually, the highest paid programmers are ARM embedded developers that have power management disciplines for mobile and wearable systems. They work in a mix of C and ARM assembly to stretch the battery lifetime of a systems perceiving its value.

Doesn't really matter between cin and scanf, either one you can make it absute value.

Basically you will want to to take the greatest precision / size possible which is probably a "long double" when reading the number.
After that you won't have to take care of how big the number is.

If the question revolves arround having a type beforehand you can either check the size of the type ("sizeof(variable)") in an if-else construct or use some c++ operator like object_of_variable.size.

This might just become my job.
Feels good man.

Yes my only question is how to find out the type before hand

>This might just become my job.
>Feels good man.
Get good at using a voltmeter, oscilloscope and logic analyzer as well as an IDE to code. After that, fucking cash in.

these arbitrary restriction type assignments are stupid, so i might be breaking some other unwritten rule, but just implement the 3 variable one in terms of the 2 variable one

float fmax(a,b,c) { return fmax(fmax(a,b),c); }

i thought something along the lines:*/
long double nigger = 0;
cin >> nigger;
if(nigger > sizeof(double))//or a number that is non-0 is behind the comma beyond the scope of double
{
cout

i don't think you understand how sizeof works
on most modern systems:
sizeof(double)=8
sizeof(int)=4 or 8

>float fmax(a,b,c) { return fmax(fmax(a,b),c); }
Make it recursive for an indefinite list of variables passed into the function.

if (num < 0) num *= -1;

type doesn't matter

Uhh, well i would have stumbled upon that if i actually tried it (now i remember it...). Either way - the principle still works: If you compare the number you've read in with the ranges of the different types you can make an if-else construct and cast it properly when cout'ing it.

Sorry for wait; got sidetracked for a moment.

That's not terribly hard to do. Once you get the input string, you can use a method like scanf to try and turn the value into something like a double, then operate on that value. Picking a double is just personal preference. I like to always use some kind of floating point because methods like scanf can correctly interpret a whole number as a floating point number, but not the other way around. Keep in mind you should check for illegal values.

If the point of the program is to figure out the type, then you can do some checks with the size using sizeof(x), and try and reason out what type best matches it.

If the point is just to get the absolute value, you can most likely interpret the input value as a double like I wrote before and get the absolute value normally.

Recommend you also read up on stringstreams, if you're allowed to use them for the assignment. They're hella useful.

try again
3.14159 is well within the size limits for int, but it clearly isn't an int

on that note, the most important part in solving this type of stupid assignment is to know the exact set of restrictions placed on the solution

can you use stringstreams?
can you use regular expressions?
do you actually need to parse the input into some numeric data type, or can you just store it as a string and remove the negative sign if it exists?

op hasn't given us enough details on the restrictions for us to provide a valid answer

That's why i added the comment behind the if-condition - i just didn't want to write it down right now

In pseudo code:
if((nigger>maximum_number_of_double)||(nigger has a number behind the comma that is beyond the scope of "double"))
{
cout

Yeah; I know. It's why I asked how he was getting the value. If nothing else, that's at least the basic issue of the problem in my mind.

The beauty of programming; even if he can't use the way I'm presenting, he can probably use a similar method, unless the assignment has some "You have to get the absolute value of any type without multiplication" bullshit.

if this thread already exist i might post my question... anyone knows a good alternative to "recuva" to restore deleted files? I had porn OC on my HDD but i deleted it by fucking accident

help me out and i share if it works

the best alternative is called "making regular backups"
beyond that, most undelete programs essentially do the same thing. they just have different bells and whistles
if recuva isn't finding your files, you're unlikely to get them back with similar software

techradar.com/news/software/best-free-data-recovery-tools-1321723
Just use these in order and you'll get 99% of your shit back.