[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Programming is so difficult. How do you do it /g/? Write pseudocode
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 39
Thread images: 1
File: 0133985075.jpg (60 KB, 519x648) Image search: [Google]
0133985075.jpg
60 KB, 519x648
Programming is so difficult. How do you do it /g/?

Write pseudocode to represent the logic of a program that allows a user to enter two values then outputs the product of the two values. (If you're not sure of the definition of product be sure to look it up to verify its meaning.)
>>
You literally just rewrite the question, how is that difficult? Are you mentally retarded?
>>
>>54801842
For me, yes. Possibly, I wish my parents would have told me if that was the case.
>>
>>54801904
Your pseudocode:

- allow a user to enter two values
- then output the product of the two values

If you want to be more specyfic:

- allow a user to enter two values
- take the product of the two values
- output that
>>
>>54801930
Literally, just all words? I'm actually looking at my Chapter 1 PP slides for the first time. Kek.

Am I going to struggle in "Programming in C" next semester?
>>
>>54801616
Everything that requires one to put time and mental or physical effort can be considered difficult.
>>
>>54802105
It appears as though you won't pass.
>>
>>54802126
I believe I will pass Programming Logic for sure. It's summer courses(10 weeks) atm and I'm taking two math classes, programming logic, and biology. Its insanely crunched together. Math by far takes up most of my time. I have no life this summer.

Fall will at least be spread out where I can focus on "C", Calc, and Physics which will be all I'm taking. I'm considering adding Political Science just for the hell of it but probably not.
>>
>>54802311
Also, is C still useful in the big picture of programming languages?
>>
knowing how these classes are it probably wants something like this

-Declare Integer Num1
-Declare Integer Num2
-Display "Input two numbers to see their product"
-Input (num1, num2)
-Declare Integer result
-result = num1 * num2
-Display result
>>
Well first of all you need an abstract factory
>>
>>54801616
>>54802105
>>54802311

you don't know jackshit about programming logic and the first language you're going to learn is C?

I recommend that you study a LOT


also, this is one of the easiest algorythms that someone could write in pseudocode
>>
>>54801616
>Programming is so difficult
Only if you're fucking retarded.
>>
If you literally can't think of how to do this in 3 seconds, you're fucking retarded. Become a plumber you moron
>>
>>54802561
yes. you will need it for things
>>
>he thinks multiplying two numbers together is an "algorithm"
>>
>someone asks for an algorythm
> /g/ doesn't reply with 30 different ways of doing it

you lost your ways /g/
>>
>>54802829
Even plumbing requires thinking.
>>
>>54801616
int shekelsMultiplier(int myMoney, int stolenMoney)
{
return myMoney * stolenMoney;
}


Lemme fix that for ya
>>54804133
>>
>>54804309
thanks my friend
>>
Here, i'll write it in Lua for ya

print("Start")

--[[I'll walk you through this amazingly difficult language step by step, so pay VERY close attention
Uber serious HAXXOR shit going on here

also I can't spell, deal with it
]]

function productFinder(x, y)--This is the function we're going to use for our hacking. notice the (x, y), because these are our arguments.

local a = x --This is a variable, we use local so that we could use these variable names again in different functions (or to keep shit from being fucked with.)
local b = y --This is another variable
--There both set to the arguments given in the (x, y) above


local c = a * b
--[[This variable sets the c function to find the product of both the a and b variable we made before.

Now there are many ways to do this

-You could've just used the x and y arguments directly, and only had one variable
ex.(local c = x * y)

-If you don't want to use the * (for some bullshit class or something), you could of simply wrote
ex.(

local a = x
local b = y
local b_static = y

for i = 1, a - 1 do
b = b + b_static
end
)

-And if you want to be a memester, i'm pretty sure there's some one-line alternative you could write to make it look like your fucking John Charmack or something.

]]

print("The product of "..a.." and "..b.." is "..c)
--This simply prints out the variables on-screen in a way anyone could understand

end

x = io.read() --Gathers input(see:System.in, cin, or whatever pajeet shit you have in your language)
y = io.read() -- Same here, just gathering out user input

productFinder(x, y) -- Call our DDoS in, and there you go

--Now if a faggot like me can do this, so can you! So stop making threads on RedditLite, and go make something of yourself!
>>
This code in Scheme returns a function that does just that!

*
>>
>>54804449
A+
>>
Node.js!

const readline = require('readline')

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})

const question = (n) =>
`Give me your ${n} number: `

rl.question(question('first'), (n1) =>
rl.question(question('second'), (n2) =>
cb(n1, n2)))

function cb(n1, n2) {
console.log(`${n1} * ${n2} == ${n1 * n2}`)
rl.close()
}
>>
sh!

#!/bin/sh

echo -n 'First number: '; read n1
echo -n 'Second number: '; read n2

echo "$n1 * $n2 == $((n1 * n2))"
>>
Most programming is just rote memorization
>>
>>54804449
>that awful syntax highlighting
step it up, chink moot
>>
>>54802698
nice
>>
C!

#include <stdio.h>

int readnum(char *name) {
int ret;

printf("Enter your %s number: ", name);
scanf("%d", &ret);

return ret;
}

int main() {
int n1 = readnum("first");
int n2 = readnum("second");

printf("%d * %d == %d\n", n1, n2, n1 * n2);

return 0;
}
>>
Racket!

#lang racket

(define (get-num name)
(printf "Enter your ~a number: " name)
(string->number (read-line)))

(let [(n1 (get-num "first"))
(n2 (get-num "second"))]
(printf "~a * ~a == ~a~n" n1 n2 (* n1 n2)))
>>
>>54801616
>Write pseudocode to represent the logic of a program that allows a user to enter two values then outputs the product of the two values.


declare float a, b
ask for input and assign to a
ask for input and assign to b

print float, a multiplied by b

end program
>>
>>54807103
you forgot to include string.h for the %s conversion specifier anonymous
>>
>>54804449

Wow, Lua looks nice.

(sorry about that shit syntax highlight, though)
>>
>>54808603
Yeah, it's one of my favourite languages if just because of how clean it can look.
>>
>>54808562
That's not true
>>
>>54808603
That's the problem with Lua, it has little to no support.

It also isn't as secure or powerful as C++ or Python, but it's a really comfy (and surprisingly fast) language, and a great starting point for when you want to learn C++, or C, or Java.
>>
I'm starting to get it. The first chapter didn't show us how to Declare variables, create prompts, name constants, comment and the like. I'm actually liking this class.
>>
>>54808956
We were told to download Python so I suppose we will get to work with it at least some. :)
>>
>>54801616

>user enters two variables

>multiply the two variables

>prints the result of multiplying the two variables
Thread replies: 39
Thread images: 1

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.