/dpt/ - Daily Programming Thread

Anime sucks edition.

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

youtube.com/watch?v=vtQ7LNeC8Cs
twitter.com/SFWRedditGifs

Anyone want to prove their l33tness to this fine community in C# and do my bullshit assignment. This class has been sucking balls so far, the teacher is dry as fuck and we haven't even been required to use an actual computer, yet we're entering the 3rd fucking week of class. Thanks guys.

Is there any demand for DBAs or systems analysis? I'm falling in love with databases.
I don't think I enjoy it more than development but I'm definitely better at it.

That shouldn't take more than 3 to 5 minutes tops with the bottleneck being hand writing.
Is that a whole weeks worth of homework?

You should start the program by getting two(2) numbers from the user. If the numbers are equal the program should print "The numbers are equal". If the first number is greater than the second number the program should subtract the second number from the first and print the result. If the second number is greater than the first the program should subtract the first number from the second number and print the result. After the message is printed, the program should ask if they want to try again. Example: "Would you like to try again (Y/N)". Your program should read their answer and then either ask for two numbers again or end. You may use pseudo code instead of actual code but the meaning of each line should be clear.
Hope this helps. :^)

Should I learn scala? I tried java but didn't really like it
What benefits does scala hold
What's a good resource to learn

main = do
x putStrLn "The numbers are equal"
LT -> print (y - x)
putStrLn "Would you like to try again (Y/N)"
c main
_ -> pure ()

new program language c+

it like half c half c++

It would if we had a proper teacher who was actually teaching us shit. The class is actually in it's 4th week and already 40% of the students in the class have dropped. I have no idea what we've been doing so far in class, I've been taking notes, but everything we've covered doesn't seem to be of any use in completing this shit exercise.
Hilarious user, good one.

Whoops, replace getChar with getLine and c with
"Y"

can you dumb it down a bit, that looks way too technical, teach would know I fucking got this from a c# wizard. thanks man.

*and 'Y'

Didn't realise getChar works on the same line

guarantee he won't think it's from a C# wizard

Don't you mean, C += 0.5

>I've been taking notes, but everything we've covered doesn't seem to be of any use
kek, post your syllabus
>Hilarious user, good one.
I'm not kidding, the whole program is laid out right there.

Sure is new school year in here

How the fuck is the runtime of a while loop inside a for loop inside a for loop be O(N^2)??

Why would it not be O(N^3)?

i thought C was an int

youtube.com/watch?v=vtQ7LNeC8Cs

what's the loop and conditions and stuff

Right. So you'll keep using C.

best youtube video to mater c++?

Check the previous thread. Scala got brought up and some user shared some videos for it.

videos can't do that

>implying i ever used C

No mortal can master C++

I can't remember but I missed it.

How would there ever be a case when this is not O(N^3)

for(condition n

would anybody be interested in a very simple mobile app that lets you search for C library functions and basically returns the man page info for that function?

what's the condition about n

lol, no what the fuck?

also where is what being incremented

how do I explain to judges that I can do their job better than they can

wouldn't it be useful tho? to some people? in some contexts? of course at your computer you could just type "man 2 " or whatever
if 10 people in the world would get some use out of it, then that's worth it to me.

I think it was m>0 or m

The first for loop gives 1 factor of N.
The second for loop gives 1 factor of N.
The while loop could be anything, from O(1) to never halting, depending on what the condition is.

wish I could have taken a pic
n++ in the first
m++ in the second

C is all you ever need.

>The while loop could be anything, from O(1) to never halting, depending on what the condition is.
How so? What would that look like

like this

while (n.next()) //this while would be O(1)?
{
//print
}

Does anyone know of a way to find the number of value in a pointer/dynamic array? using sizeof(array)/sizeof(array[0]) unfortunately doesn't work because they're pointers
I can do it fine while creating the array, but for part of my homework i'm supposed to find it in a separate function, only passing in the array and the total length

if it's m

if n.next() only returns true once

e.g.
bool b = true;
while (b) {
print(b);
b = false;
}
print("end of program")

output is:
>true
>end of program

There is no way to get the length of something from a pointer alone.
It needs to be passed around somewhere else.

ah fuck me

Thanks guys

Your question doesn't make sense. You're supposed to find the "number of value" in a dynamic array only passing in the array and the total length?

You should look into "Data Engineer" and similar roles

*Number of values, sorry
But yeah, the first part of the assignment was to read in a .txt file of unknown length, and put each word into an array, doubling the capacity of the array each time it filled up before reaching the end of the file.
I did this using temporary arrays and for loops, and so I was just able to get the final 'i' from there which is basically the number of words in the .txt file, but I'm supposed to find that same value in this other function.
sorry if my terminology's off, I'm still pretty new to c++

By all means, make it. But just remember people usually program on a PC and library function definitions and examples are a ctrl+tab away

At what point is state okay and what point is state bad?
int add(int x, int y); //returns x+y
int add(int &x, int y); //x+=y
int add(struct x, int y); returns x.y += y
int add(struct &x, int y); //x.y += y

Doesn't object oriented programming boil down to the last add function (hence all of this "this" keywords in Python OOP)
Why is the last one considered bad when it's really no different than the first one? The only difference is that it's modifying a variable to allow for better optimization

state is only ok when you're optimising code

yeah dude, still have no fucking idea what you're assignment is. take a pic or something, I can probably give you a helpful hint or clarify something.

This wouldve been helpful to me when studying for my C programming class this time last year. Wouldve been handy when I was away at work and stuff. Make it anyway.

Er fuck. I should say the last two returns a struct and it returns x after the operation is done
That's my bad, wrote that on my phone

SCALA IS A SCAM. DON'T LEARN IT. IT'S FOR NUMALES AND PAJEETS WEBSEVS. NOT REAL PROGRAMMING

good advice

it seems like he got the array size couldn't he return it and pass it using generics?

Ok here's a really condensed screenshot. Basically, I'm filling array[] with words from a text file that has less than 50 words, and I'm supposed to find how many words there are using a separate function that takes the array and size as parameters, instead of just counting how many I put in.

Thanks. That was one of the scenarios I was imagining in my head. I'm also thinking it might be useful in a situation in which two devs are having a discussion about C functions or some code they're writing, and they happen to be away from the computer. Or perhaps lying in bed at night, and the C library is just so beautiful...
I'm thinking tho, of how I would implement it. I'm guessing grab the GNU C library man pages, and then parse those into different sections for each function for each page? like
strtok - extract tokens from strings
Synopsis: (shown already)
[+] Description
[+] Return Value
[+] Attributes
[+] Example
[+] See Also

oh. couldn't you just iterate through the array until you reach a null word?

Iterate until you find a non-value

Also, your word structure...is count the number of times that word appears in the text file?

I've been trying to, but it always either returns 0, or goes all the way through the array.
Is my syntax just messed up?
Yeah, but they're asking that this function return all words, even duplicates

Forgive my retardation...
Do SSDs affect compile time?

Using esoteric languages to give solutions to easy homework questions is my favorite thing.
(defun main ()
(loop
(let ((x (parse-integer (read-line))) ;; No error checking bois :^)
(y (parse-integer (read-lne))))
(cond ((= x y)
(format t "The numbers are equal"))
(t
(format t "~a" (- (max x y) (min x y)))))
(when (y-or-n-p "Would you like to try again?")
(return)))))

That'd be pretty cool desu. Are you going to start up on github?

If I ever wrote C like language I would most definitely call it C_ read “C flat”

>Doesn't object oriented programming boil down to
No.

>Why is the last one considered bad
It's not.

State is not necessarily good or bad. It's the context that decides if you should apply it.

why isn't your loop exit condition "i < size"?
why are you comparing a int value to NULL?
why aren't you using a simple counter, and when you encounter a nullptr, you just return the count?

like this:
int getTotalNumberWords(Word array[], int size) {
int count = 0;
for (int i = 0; i < size; ++i) {
if (list[i].word == nullptr) {
return count;
}
}
return size;
}

btw, in C++, you should use nullptr instead of NULL

I wouldn't think so. Not unless your compiler can't get your program and itself to fit into RAM.

That's not how you write flat.

i would call it D because D>C

Are you just saying you like D?

The size/length thing was because I was copying and pasting bits from my messy homework to the cleaner example.
I actually just got it to work using
if(array[i].word.empty()){
return count;
}
But ok. I kept getting errors trying to see if the string equaled NULL. Is nullptr for strings? or does it just tell if the pointer is pointing to anything?

Well yes but it’s a bit tongue in cheek

No, I just like the idea of everyone playing with my D for decades.

nullptr is for anything really.
Here - let Bjarne Stroustrup tell you about it:
" In C++, the definition of NULL is 0, so there is only an aesthetic difference. I prefer to avoid macros, so I use 0. Another problem with NULL is that people sometimes mistakenly believe that it is different from 0 and/or not an integer. In pre-standard code, NULL was/is sometimes defined to something unsuitable and therefore had/has to be avoided. That's less common these days.

If you have to name the null pointer, call it nullptr; that's what it's called in C++11. Then, "nullptr" will be a keyword. "

Hey, it's me again, trying to do my bullshit assignment. Working with my good friend bob since no one could help me out really, except for that wizard user that was trying to get me in trouble.

Anyone know why I'm getting the red squiggly lines underneath Console.ReadLine();. I think it may have something to do with it not being a string, thanks guys. Time is of the essence, shits due in like 7 hours.

Thanks.

Convert.ToInt32(Console.ReadLine()); is what you most likely want, babe.

Maybe you should start on your assignments earlier?

Welp, just uploaded it, and it turns out my answer wasn't right. It just wanted me to add up all the 'count's in the struct.
Thanks, though, I do feel like I learned something regardless. I should've noticed when the error message said it couldn't set a string equal to a long int

You're trying to assign a string to an integer. Next time try reading the error and thinking critically before posting on /dpt/.
He's too busy playing pokemon.

...

Do you like it Sup Forums?

>Write a program (on paper NOT on a computer)
yeah you're fucked.

Maybe I should user but I spent all my time today talking to qts on the waifu discord server. I prioritize my tasks man, I'm actually talking to fembots.

>He's too busy playing pokemon.
tfw you have a 100 line C program due tomorrow and you haven't even started

It's fine.

Those were men. Also, talking to girls doesn't count unless you've met them IRL.

wow so diverse

i really appreciate the fact that the black woman is the voice of reason and the white man is a total retard and nerd

very realistic

They weren't men dude. I was actually talking to two over voip, don't be jelly user. Maybe if you help me out with this bs assignment, I'll give you the Skype name for the fatter one.

Fucking kids. I bet you're one of those
> I just wanna make games bro
or
> Hell yeah I heard CS grads make bank dude
You clearly do not give a fuck. You might be able to slime your way through college, but the little charade won't last long once you're working on real software.

Calm down, kiddo. That's copy pasta.
>tfw you have a 100 word essay due tomorrow and you haven't even started

Don't worry, m8. When they graduate 12 years from now their jobs will already have been taken by AI. They won't even be able to land a service job because demands for $30/hour minimum wage have driven all those towards automation.

Nope neither. Planning on working in the infrastructure side of IT, fuck programming. Stupid program is making take like two programming classes though.

If I wanted a girl again I'd just start doing things that girls like to do again. Also, why are you bragging about having a fat girl chatting with you over the internet?

>tried Java but didn't really like it
then you'll hate Scala

You'd be better off with Haskell if you want to get into functional programming

TDD ends up with you writing 20 tests for a standard library. But check out the loc.

The C++ Programming Language, 5th Edition WHEN

dumb frogposter