[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Hey /g/, I really don't know who else I can turn to I have

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 142
Thread images: 15

File: Untitled.png (55KB, 594x727px) Image search: [Google]
Untitled.png
55KB, 594x727px
Hey /g/, I really don't know who else I can turn to

I have an assignment in my C++ class and it seems fairly simple at first, but the second part of it got me a bit lost (pic very related);

How would one go about letting a user put in a conversion factor and then build a table out of first 10 values with the conversion factor provided?

Thank you for your input
>>
File: Untitled2.png (10KB, 912x395px) Image search: [Google]
Untitled2.png
10KB, 912x395px
>>55788140
OP here, this is what I got so far, it's my first C++ thing I ever did so it's probably retarded
>>
>>55788152
Consider switching majors

Just cin a float for conversion factor then multiply 1-10 by the factor and print it out as a nice pretty table.
>>
>>55788140
A for loop will let you do this in 2 lines of code.

Maybe programming isn't for you?
>>
>>55788338
>>55788335

I know it's not, but I need it for my logistics major, I just want to pass it and forget it

So it would be something like

double x;
cin >> x;
cout << "The conversion is:" << (1)*(x), (2)*(x)

and etc?
>>
>>55788528
Fuck off and pay a classmate to do your homework, you dumb MBA-shitter.
>>
>>55788528
pretty much. Most of the programming is pretty printing. Its just multiplication.

There are better ways to do it, but even you should be able to hack out a solution in at most 10-15 minutes
>>
What the fuck, OP.
The instructions clearly state the expected output, and you immediately start typing bullshit and adding typos. Convertion? wtf is that.
Please go to office hours.
You are not going to pass this class.
>>
>>55788649
"... into the destination currency, using conversion factor provided by the user", and thanks for pointing out the typo, that happens to me some time since English isn't my first language пeтyшoк oбocцaный
>>
>>55788140
jesus christ op
this is pre programming knowledge
literal bottom of the barrel shit
>>
>>55788152
EXPECTED OUTPUT:
Options:\n
1: USD -> EUR\n
2: EUR -> USD\n
\n
Please select an option:

YOUR OUTPUT:
Hello,\n
\n
Press 1+Enter to do a dollars to euros conversion, Press 2+Enter to do a euros to dollars conversion :

FUCKING CAPSLOCK IM SO MAD
If i was grading this I would give you a 0 even if it worked perfectly.
How are graders supposed to diff output when no1 pays attention to guidelines.
>>
>>55788780
I didn't know how to make it the right way lol
>>
>>55788140
Protip: use boolean for the options, as you dont need more than 2 options
>>
File: 1459989421646.jpg (8KB, 250x237px) Image search: [Google]
1459989421646.jpg
8KB, 250x237px
>>55788780
wew lad you mad?
>>
>>55788835
It's literally just type what you see them asking you to type. Make it look like theirs. Even Dudley from the Royal Tenanbaums could do that one. Please fix the output, and I'll be glad to help with the rest of the logic.
>>
cin.get(x)
a = 0
For (i = 1; i < 11; i++)
a = i*x+ a
cout << "The current rate is: " + a

Idk at all how coding works but i looked up a little real quick for you.
>>
File: 3.png (16KB, 798x570px) Image search: [Google]
3.png
16KB, 798x570px
>>55788884
>>55788780
>>55788649
is this better?
>>
>>55789001
that looks like it has potential in it, looking into it now
>>
>>55789011
Delete the first two cout lines.
Also using namespace is bad practice, but that's okay in this kind of program.
Once you get the conversion rate from standard input, print the EUR USD table header and then all you have is a for loop to write.
for (int i = 1; i <=10; i++) {
cout << i << " " << i*conversion_rate << endl;
}
return 0;
>>
>>55789085
Im a dumbass friend, forgot define the int.

cin.Get(x)
a = 0
For (int i = 1; i < 11; i++)
{
a = i * x + a;
cout << "The conversion is: " << a << "$" << endl;
}


Fixed it up, did it as the ONLINE MANUAL said I should. Hope it helps OP
>>
>>55789001
this is super wrong
>>
>>55789197
super wrong v2.0
>>
>>55789011
Where in the program does it ask you to say hello?
>>
>>55789197
hilariously incorrect I LOVE THIS THREAD
>>
>>55789236
Like i said breh. No clue how c++ works, whats wrong about this
>>
>>55789276
every time you go through the loop, you're adding a to itself and then also adding the conversion rate multiplied by i.
All the question asks is to print i*conversion rate in increasing order from 1 to 10.
>>
>>55788528
Cin and cout are fucking retarded. They are objects that use bit shift operator to print or read text. Why the fuck? What was wrong with printf function?
>>

float factor;
cin >> factor;
int i, value;
cout << "Dorrar \t Euro"
for (i=1; i <11; i ++){
value = i * factor;
cout << i << " \t " << value;
}

>>
>>55789302
agree. love me some printf.
>>
>>55789293
Really? I made it so that it output a every time it added i * x to a
So i figured it would do

i * x + a = 1.4
Then on the next pass its -
Okay yeah i see where the mistake is. Thanks anon i'm an idiot
>>
>>55789254
well, it must greet the user, am I wrong?
>>55789187
thank you, gonna be testing it now
>>55789197
no problem bud, any input is nice lol
>>
>>55789302
>>55789336
I don't like printf.
Overloaded operators 4 lyfe.

No, really, printf has the look and feel of deprecation compared to cout.
>>
>>55789320
Thank you, I'm starting to get something out of that, but for some reason it abruptly disappears
>>
>>55789336
>yfw printf is slower than std::cout
>>
>>55789434
You have no idea what you're talking about.

C style variable arguments are great and consistent.

Stream operator overloading with the bitwise shift operator is the epitome of shit.
>>
>>55789549
lol it isn't slower. You're funny though.
http://stackoverflow.com/questions/2872543/printf-vs-cout-in-c

>>55789434
Somewhat valid, cout adds inheritibility and all that shit listed on stackoverflow.
Not that stack overflow isn't often wrong.
>>
Hello, so I am hearing you are having troubles with your HW assignment? No problem friend. I will assist you with your problem.
int euro=0;
int usd=0;
int xRate=0;
int choice=0;
int obama=1;
cin>>choice;
cin>>xRate;


while(choice!=0&&obama){
if(obama)
{cout<<usd*xRate<<endl;}
if(obama==1)
{
cout<<usd*xRate<<endl;
}
if(obama==2)
{
cout<<usd*xRate<<endl;
}
if(obama==3)
{
cout<<usd*xRate<<endl;
}
if(obama==4)
{
cout<<usd*xRate<<endl;
}
if(obama==5)
{
cout<<usd*xRate<<endl;
}

if(obama==6)
{
cout<<usd*xRate<<endl;
}

if(obama==7)
{
cout<<usd*xRate<<endl;
}

if(obama==8)
{
cout<<usd*xRate<<endl;
}

if(obama==9)
{
cout<<usd*xRate<<endl;
}

if(obama==10)
{
cout<<usd*xRate<<endl;
}
obama++
}

Have I given you satisfactory customer service?

>>this is a very bad example and won't work because the algorithm is shit. Do not use or try this for it is a crudely written meme. Avoid chaining if statements like this.
>>
>>55789479
Guessing you're using an IDE like VS.
Try just running the binary from the cmd.
Or add 'getch();' before the closing brace.
>>
>>55789581
lol'd.
Also is there some <code> tag I don't know about? It looks like there is.... shit
>>
File: 1461361949666.jpg (36KB, 356x374px) Image search: [Google]
1461361949666.jpg
36KB, 356x374px
>>55789581
thank you very much for you input friend, your warmth will caress me in the night
>>
>>55788152
>using namespace std
kek
>>
>>55788140
for (int i = 1; i <= 10; i++)
printf("%d\t%.1f", i, (float) i * factor);


If you can't even figure this shit out, change majors NOW
>>
>>55789648
already mentioned that
>>55789187

not that he cares or even a grader would care
>>
>>55789658
he's not a CS major
fuck, am I the only one in this thread that reads other posts?
>>
>>55788140
Okay I will be the autist here. Run this. Use std::setw to format the table

#include <iostream>
#include <string>

typedef enum {
UsdToEur
, EurToUsd
} ConversionFactor;

int main(int argc, char** argv)
{
ConversionFactor eOpt;
float fFactor;
std::string sFrom, sTo;

std::cout << "USD->EUR" << std::endl;
std::cout << "EUR->USD" << std::endl;
std::cout << "Please select an option:";
std::cin >> *(int*)&eOpt;

//Check conversions
if (eOpt == ConversionFactor::UsdToEur)
{
std::cout << "Please insert the conversion factor (USD->EUR):";
sFrom = "USD";
sTo = "EUR";
}
else
{
std::cout << "Please insert the conversion factor (EUR->USD):";
sFrom = "EUR";
sTo = "USD";
}
std::cin >> fFactor;

std::cout << sFrom << " " << sTo << std::endl;
std::cout << "_______________________________________" << std::endl;
//Print Table
for (int i = 1; i<=10; ++i)
{
std::cout << (float)i << " " << (float)i * fFactor << std::endl;
}


return 0;
}
>>
>>55789571
Chances are you are right but I still prefer cout over printf.
>>55789576
cout just seems easier and more flexible than using printf.
>>55789479
>>55789602
Definitely sounds like VS. When I was taking courses, I resolved to use system("pause") because it was the quickest answer google could give me. It's a bad practice and I've long since stopped.
A better way to do stop VS from closing the console window without constantly adding a line to your programs just for that is to use the feature "Run without debugging" , or, ctrl+f5 (you can add the button to the window frame, too).
>>
>>55789685
+1 for casting to float
-10 for unsafe casting
>>
>>55789679
i'm not a CS major either

this is basic math
>>
>>55789679
Lol

CS is for people who are to dumb for math and too dumb for science
>>
>>55789648
It's what they're teaching students to do these days. Sure enough, it's confusing as fuck to a complete novice when they go online to seek help and see std:: prefixing a bunch of things that their textbook would print plainly, ie cout and vector.
>>
>>55789730
Nope, CS major here. Minor in math. Always did better in math courses. Could have switched to double major but I prefer CS courses for their focus on application.
>>
>>55788152
WHY are you using VS?
WHY are you coding in Windows?
>>
>>55789750
We did it Reddit!
>>
File: 1466181166769.jpg (223KB, 722x830px) Image search: [Google]
1466181166769.jpg
223KB, 722x830px
>>55788140
>>
>>55789754
yeah, especially with c/c++. At least use cygwin, super easy to install just make sure u check the boxes for gcc/g++ and vi/vim (if available).
>>
>>55789479
Press Windows key + r
Type cmd
You should see "C:\Users\yourusername>" with a blinking _
Type cd (meaning change directory) (DON'T PRESS ENTER)
Now, the goal is to change to the directory with your Visual Studio project
By default, this is C:\Users\you\Documents\Visual Studio 15\Projects\projectname
You can type part of the directory name and press Tab to complete it
For example, you start out with C:\Users\you
type cd Doc and press Tab, and it will automatically complete to look like
cd Documents

You can press \ (backslash) and then type another folder name to complete the name of a folder inside Documents
For example, you have
cd Documents\Vis
and you press Tab, and it changes to
cd "Documents\Visual Studio 15"
(the quotations are necessary because the directory name has a space)
Then delete the last quotation mark, press \ (backslash), start typing the name of the project, press Tab
Make it so it looks like
cd "Documents\Visual Studio 15\Projects\projectname\Debug"
(15 may be a different number)
After that press Enter.
Not it should say
C:\Users\you\Documents\Visual Studio 15\Projects\projectname\Debug>

Start typing the name of the project and press Tab. It should autocomplete to something like
projectname.exe

Press Enter, and you should see the output of your program.
>>
>>55789772
huh?
>>
>>55789781
>cygwin
Good G*d, no!
>>
>>55789803
Should've majored in tripal integrals instead
>>
>>55789805
Hey, I hate emulating too, but definitely better than whatever windows IDEs are out there.
>>
>>55789700
C style casting is perfectly valid if the types are integral.
You can replace it with static_cast if you're that anal about it.
>>
>>55789794
This is why people learning to code shouldn't use IDEs fyi
>>
>>55789827
>tripal integrals
Showing results for triple integrals instead
Search instead for tripal integrals?
God I hope you don't have a college degree.
>>
Now that OP's homework has been done by autists can we talk about 17-dimensional hypercubes?

PLEEEEEASE?
>>
>>55789831
No. Windows has a great ide for Windows development. Cygwin is a bandaid for lazy people and you are better off going mingw or just full linux instead
>>
>>55789845
>my little shitposter cant be this new
>>
When I was doing HW assignments, I would always favor using double over float. Something about decimal number precision iirc. So, basically anything that had me print or use a number with several decimal places was full of double declarations instead of float. How dumb was that?
>>
>>55789867
I'll take your word for it.
I really don't like cygwin either but it's closer to Linux and you don't have to fuck around with IDEs and waste your brain on autocomplete.

>>55789862
http://math.stackexchange.com/questions/1506617/perfect-matching-in-n-dimensional-hypercube
Let's talk, homie.
>>
>>55789794
holy fuck this is hard mode.
just use "start without debugging" / ctrl+f5
>>
>>55789883
Float is expensive. At that level final decimal precision can probably be handled with doubles
>>
>>55789888
If you want something "closer to Linux" I emplore you to use mingw then.
>>
>>55789904
Okay, what?
Am I the only one who thinks this guy might have brain issues, or am I a complete idiot?
>inb4 both
Doubles are double precision (64-bit) whereas floats are 32 bit single precision.
How is float more expensive than double?
>>
>>55789901
>this is hard mode.
Literally all he is doing is changing directory on a command line and then running a program.
That is the most basic you could possibly do.

Do winplebs really not know how to use an operating system?
>>
>>55789931
No, I'm a Linux fag, definitely only use windows for the occasional game, but it's been months since I booted into win7. Not looking to do any development on windows.
>>
>>55789934
literally all he is doing is expending a lot more energy with the manual labor of typing and clicking and typing and clicking when even litterally adding one dumbfuck line to every program would be easier literally
>>
>>55789904
You mean these?
>>
>>55789932
If I'm not misunderstood float uses IEEE standard, with mantessas and shit, while double is just a wide integer basically
>>
>>55789934
Just scanning his long ass post made it seem like a lot of shit just to keep it from exiting immediately. I still haven't read that whole thing. Shoulda put a tl;dr at the end.
>>
>>55789932
>>55789963
See, this is why I thought using doubles errywhere was fine but then I read that floats are 4 bytes whereas doubles are 8, thus, potentially wasteful (even if it was for the simple shit I was doing).
>>
>>55789957
;-)
>>
>>55789963
Single precision (float) gives you 23 bits of significand, 8 bits of exponent, and 1 sign bit.

Double precision (double) gives you 52 bits of significand, 11 bits of exponent, and 1 sign bit.

Both use encoding and need to be decoded.
Pretty sure I'm correct in saying that doubles are heavier than floats in both space and decoding complexity.
>>
>>55789754
>calling people out while unironically referring to programming as coding
>>
>>55789985
Good call, but the perf difference is more from calculation time than mem size
>>
>>55789997
But I'm liking this discussion and would love to be proven wrong.
>>
>>55790023
see
>>55789997
amiwrong?
>>
>>55789997
Doubles are NOT heavier than floats. What exactly do you think a FLOP is?
>>
>>55790003
Enlighten me
>>
>>55790040
floating point operation.
Where's your argument exactly?
Would still love if someone would prove me wrong. Keyword: prove.
>>
i made the code to the 2 option.
i'm beginner too, notations are in portuguese
int choice;
cin >> choice;
if (choice==2){
cout << "\nType cotation value.";
float x;//Valor de troca ex: 1usd = 1.4 EUR
cin >> x;
int i;//i=moeda no caso 1 vai ser o dolar
for (i=1;i<11; i++){
cout << i;
cout << "Euro equivale a ";
cout << i * x;
cout << "USD\n";
cout <<", ";
}
}


}
>>
>>55788140
hey OP i did your homework

I'll post the solution if you post a timestamped picture of yourself holding a sign saying "MAKI MAKI GIMMIE DAT FAKI"
>>
>>55790058
People use FLOPS because a flop is the most expensive operation, making it a more meaningful measure of power.
>>
Doubles are double-precision floats.
AKA they are just bigger floats (4 bytes larger, so obviously in terms of space they are heavier)

I'm beginning to think this thread is 99% trolls.
>>
>>55790085
hahhaaaa

What year are you?
Take a fucking proof class please
>>
>>55790110
Not an argument

I've graduated. Tell me what I said wrong...
>>
>>55789739
senpai pls
>>
>>55790134
Okay, here's what your mistake was:
While doubles should be the default in modern programs, floats are less resource intensive. Doubles are literally double precision floats. WTF
>>
File: google is hard.png (315KB, 3070x1080px) Image search: [Google]
google is hard.png
315KB, 3070x1080px
>>55789739
>>55790144
fucking god it said the image was attached but it wasn't
>>
>>55790085
>People use FLOPS because a flop is the most expensive operation, making it a more meaningful measure of power.
People use flops because the vast majority of supercomputers are interested in floating point operations for their calculations.
>>
File: anon hw 1.png (7KB, 431x321px) Image search: [Google]
anon hw 1.png
7KB, 431x321px
Haskell

{-# LANGUAGE UnicodeSyntax #-}
import Control.Monad (forM_, foldM_)
import Numeric (showFFloat)

data Currency = USD | EUR
deriving (Eq, Show, Read)

main ∷ IO ()
main = do
let to = (,)
let conversions = [USD `to` EUR,
EUR `to` USD]
let printConv (a,b) = show a ++ " -> " ++ show b
putStrLn "Options:"
foldM_ (\i x → do
putStrLn $ show i ++ ": " ++ printConv x
return (i + 1)
) 1 conversions

putStr "\nPlease select an option: "
option ← read <$> getLine ∷ IO Int
let choice@(from,to) = conversions !! (option - 1)

putStr $ "\nPlease insert the conversion factor (" ++ printConv choice ++ "): "
factor ← read <$> getLine ∷ IO Double

putStrLn $ concat [ "\n", show from, "\t", show to ]
putStrLn $ replicate 16 '-'

[1..10] `forM_` \i →
putStrLn $ show i ++ "\t" ++ showFFloat (Just 1) (i * factor) ""


as close to pic as I could get
>>
>>55790165
finally someone comes to my aid
thank you sir
>>
>>55790172
Nice dude
>>
Rate mine.
#include <stdio.h>

int main(void)
{
char *cur[] = { "USD", "EUR" };
char *ins[] = { "Please select an option", "Please insert the conversion factor" };
int option = 0;
float factor = 0.0f;

printf("Options:\n");
printf("1:%s->%s\n", cur[0], cur[1]);
printf("2:%s->%s\n", cur[1], cur[0]);
opt: printf("\n%s: ", ins[0]);
fscanf(stdin, "%d", &option);
fac: switch (option)
{
case 1: printf("%s (%s->%s): ", ins[1], cur[0], cur[1]); break;
case 2: printf("%s (%s->%s): ", ins[1], cur[1], cur[0]); break;
default: goto opt;
}
fscanf(stdin, "%f", &factor);
if (factor < 0)
goto fac;
else
{
switch (option)
{
case 1: printf("%s\t%s\n", cur[0], cur[1]); break;
case 2: printf("%s\t%s\n", cur[1], cur[0]); break;
}
int i;
for (i = 0; i < 50; i++)
putchar('_');
putchar('\n');
for (i = 1; i <= 10; i++)
printf("%d\t%.1f\n", i, (float) i * factor);
}
return 0;
}
>>
File: 1469326283264.jpg (75KB, 640x480px) Image search: [Google]
1469326283264.jpg
75KB, 640x480px
This thread has been closed as off-topic. Please read the sticky next time.
>>
>>55790151
Fuck. I think I confused it with long or something. MY BAD
>>
>>55790201
it's okay I'm just glad you weren't right.
I love you man
>>
>>55790220
Fuck you
>>
File: old-guy.jpg (349KB, 2000x1000px) Image search: [Google]
old-guy.jpg
349KB, 2000x1000px
>>55790233
>>
>>55790157
Okay but what I meant earlier was it can be confusing for a novice to read lines of code with that prefix all over the place when they know dick about reading lines of code as it is. And that is probably why newer textbooks (even Stroustrup's 4th edition of the C++ Programming Language) use it in their examples : because it's probably easier for the noob to read the syntax they're trying to learn .
>>
>>55790238
That said, what do you mean by "doubles should be the default in modern programs"?
>>
>>55790233
>>55790238

fuck both of you
>>
>>55790250
yeah i know what you meant anon im just fucking around
>>
File: p280047_b_v7_aa.jpg (67KB, 480x720px) Image search: [Google]
p280047_b_v7_aa.jpg
67KB, 480x720px
>>55790271
I'm out of response images until a thread is archived so here you go
>>
>>55790271
OP, ill be glad to offer more help if you need it
>>
>>55789934
>winplebs
>knowing to use an os
nice one anon.
in all reality most people probably do so instead of that wall of text here's a simpler version:
change the current directory to your project and run it you dumb fuck
>>
>>55790355
thanks for the tl;dr I honestly couldn't read that whole thing
>>
>>55788140
isn't this (conceptually) the first program after "hello world" in K&R?
>>
>>55790434
Feels that way
But i don't know what K&R is
>>
File: almost.png (80KB, 719x741px) Image search: [Google]
almost.png
80KB, 719x741px
>>55790434
close.
Similar, but not quite.
>>
>>55790477
well, that's why I said conceptually
>>
fuck you OP. now you're wasting my time trying to figure out how to pretend brainfuck has floats in the name of "fun"
>>
>>55790696
you only need the result to 1 dp

just multiply the factor by 10
and divide the results by 10
>>
>>55789187
>Also using namespace is bad practice
not OP but why is that?
>>
>>55790768
so
>user inputs number likd "3.4"
>store internally as 34
>print decimal before the last digit whenever printing
maybe I can figure out how many decimal places the user inputs and adjust where I print the decimal on output accordingly. I don't have to worry about having to print more decimal places than user inputs since you only multiply by integers.
>>
https://hackage.haskell.org/package/ImperativeHaskell-2.0.0.1/src/Main.hs
>>
++++++++++[>+++++++++++>++++++++>++++++>+<<<<-]>>-.<++.++++.-----------.++++++.
-.+++++.---------------------------------------------------------.>>>.<<<------
---.>>--.>++++++++++++++++++++++.<<++++++.--.>++++++++++.>.<<<----.>-----------
----------.<-------------.>>+.++++++++++++++++.---.<<----------------------.>--
----------.++++++++.>>.<<+++++++++++.>+++.---.>.+++++++++++++.<<-------.-------
-----------------------.>+++.--.>+++++++++++++++++++++++.<<<..+++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++.>>+++++++++++++++++++++++
++.>+++++++++++++++++++++++++++++++++.<<<+++++++++++++++++.++++++++++++++++++.>
>>.<<.<.>>>.<.>.--.<++++++++.<.>>--.+++++++++++++.<<.<----.+.>>.<<-------.>>>+.
-.----------------------------------------------------.<<.>>--------.----------
------------------------------..++++++++++++++++++++++...<<.+++++++++++++++++++
+++++++++++++++++++++++++++++.<+++.-------.>+++++++++++++++++.>-.<++++.>>.<<+++
+.+++++.+++++.<.>-.++.>>.<<.<+++.---.>>>.<<<--.>>----.-.<++.<++.>----.+.-------
---.>+.-.>.<<---.<----.>---.>++++++.-----.+++.>.++++++++.<<--------------------

1/2
>>
>>55791050
----------.<------------.---.>>>+++++.<<<--------------------.>>---------------
--------------.--.---------------.>----.<----------.--------------------------.
<<-------------.---.+++..>>----------------------..<.++++++++++++++++.---.>++++
++++++++++++++++++.......<+++.--.---------------.>----------------------.++++++
+++++++++++++++++++++++++++++......<-----------------------.......>------------
-----------------------.<++++.>>---------........<<<.---.>..>.<+.<-------------
-..>>>......<<.>>++++++++++++++.++++..<.<+.-------------------...<...>..>>+.---
--.+++++..<.>+.<++++++++++++++++++++++........++++++++++++++++++++.>------.<..<
<----------------------.>>+.>--------------......<<..>.-------.+++++++..<<.>>+.
<..>>......<.<++++++++++++++.++++++++..<.>+.>----------------------.>..<.....<.
---------.+++++++++..<.>+.<++++++++++++++++++++++....>>>..<..<.----------.>++++
++++++++++++++++++++..>----------------------.<+.-------------------------.<---
-----------.<..>....+++++++++++++++++++++++++.<++++++++++++++.>..>>.<<--------.
-.>.......<+..<.>.>>..

2/2 :^)
>>
>>55791050
>>55791063
well done a-non
>>
>>55791063
What tools do you use (to help generation/code)? Be honest, for interest.
>>
For some reason my cast doesn't work
#include <stdio.h>

/* prints conversions between USD and EUR */
int main(void)
{
int option, i;
double conversion;

printf("Options:\n");
printf("1: USD -> EUR\n");
printf("2: EUR -> USD\n");
printf("\nPlease select an option: ");

scanf("%d", &option); /* get option */

if (option == 1)
printf("\nPlease insert the conversion factor (USD -> EUR): ");
else if (option == 2)
printf("\nPlease insert the conversion factor (EUR -> USD): ");
else {
printf("\nThat is not an option\n");
return -1;
}

scanf("%f", &conversion); /* get conversion */

if (option == 1) {
printf("\nUSD\tEUR\n");
for (i = 1; i <= 10; ++i)
printf("%d\t%.1f\n", i, (double) i * conversion);
}
else if (option == 2) {
printf("\nEUR\tUSD\n");
for (i = 1; i <= 10; ++i)
printf("%d\t%.1f\n", i, (double) i * conversion);
}

return 0;
}
>>
>>55791105
There's a neat genetic algorithm here to help print text http://esoteric.voxelperfect.net/files/brainfuck/util/textgen.java
>java
I know, but it does a great job

There's also http://esolangs.org/wiki/Brainfuck_algorithms and http://esolangs.org/wiki/Brainfuck_constants which have some really useful snippits.

There's a few debuggers and some macro compilers available that I'd be using if I were serious.
Check out http://esoteric.sange.fi/brainfuck/utils/mandelbrot/ for an example of some usage of macros.
>>
glad you people know how to have fun on a bottom tier thread made by a child.
>>
>>55791106
fixed it
#include <stdio.h>

/* prints conversions between USD and EUR */
int main(void)
{
int option, i;
double conversion;

printf("Options:\n");
printf("1: USD -> EUR\n");
printf("2: EUR -> USD\n");
printf("\nPlease select an option: ");

scanf("%d", &option); /* get option */

if (option == 1)
printf("\nPlease insert the conversion factor (USD -> EUR): ");
else if (option == 2)
printf("\nPlease insert the conversion factor (EUR -> USD): ");
else {
printf("\nThat is not an option\n");
return -1;
}

scanf("%lf", &conversion); /* get conversion */

if (option == 1)
printf("\nUSD\tEUR\n");
else if (option == 2)
printf("\nEUR\tUSD\n");
for (i = 0; i <= 50; ++i)
putchar('_');
putchar('\n');
for (i = 1; i <= 10; ++i)
printf("%d\t%.1f\n", i, i * conversion);

return 0;
}


>>55791380
shhh it's midnight and I have nothing to do
>>
>>55791380
I was meming with the brainfuck but I actually am writing this in a fun esoteric language since it's 3am
>>
>>55790782
accidentally overriding std functions
other things i dont remember
>>
This fucking thread.

Holy kek.
>>
>>55788140
Are you serious?
>>
File: 1467298412461.png (269KB, 640x480px) Image search: [Google]
1467298412461.png
269KB, 640x480px
>>55792473
>>55792456
>>55791898

OP here, go home lads, I've turned in my assignment 2 hours ago, how is this thread even alive?
>>
>>55792686
I will keep this thread alive as a monument to kek.
>>
>>55788152
Always use endl instead of/n for portability.
>>
File Edit Options Buffers Tools C++ Help                                                                                                                 
#include <iostream>

int main()
{
int opt=0;
double conv=0;

std::cout << "Options:\n1: USD -> EUR\n2: EUR -> USD\n\nPlease select an option: ";
std::cin >> opt;
//If not an int always 0

if (opt == 1)
std::cout << "\nPlease insert the conversion factor (USD -> EUR): ";
else if (opt == 2)
std::cout << "\nPlease insert the conversion factor (EUR -> USD): ";
else {
std::cerr << '\n' << opt << " Is not an option\n";
return (1);
}

std::cin >> conv;

if (conv > 0) {
std::cout << "EUR\tUSD\n___________\n";
for (int i=1;i<11;i++) {
std::cout << i << '\t' << i*conv << '\n';
}
}
else {
std::cerr << "The convertion factor is too low\n";
return (1);
}

return (0);
}
>>
What's the next assignement?
>>
#include <stdio.h>

int main(void)
{
int n;
double f;
char *s[] = { "USD EUR", "EUR USD" };

fputs("Options:\n1: USD -> EUR\n2: EUR -> USD\n\nPlease select an "
"option: ", stdout);
if (scanf("%d", &n) != 1)
return 1;
if (n != 1 && n != 2)
return 1;
fputs("\nPlease insert a conversion factor (EUR -> USD): ", stdout);
if (scanf("%lf", &f) != 1)
return 1;
if (n == 1) {
if (f == 0.0)
return 1;
f = 1 / f;
}
printf("\n%s\n---------------------------------------------------------"
"-----------------------\n", s[n - 1]);
for (n = 1; n <= 10; n++)
printf("%-11d%g\n", n, n * f);
return 0;
}
Thread posts: 142
Thread images: 15


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.