monyet.cc
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
@jroid8@lemmy.world to Programmer Humor@lemmy.ml • 2 years ago

know the features of your language

lemmy.world

message-square
145
fedilink
622

know the features of your language

lemmy.world

@jroid8@lemmy.world to Programmer Humor@lemmy.ml • 2 years ago
message-square
145
fedilink
  • @drolex@sopuli.xyz
    link
    fedilink
    17•2 years ago

    Loads of beginners in this thread. Here’s how it’s done in the industry.

    The code:

    return a;

    The test:

    a = rand()%100+1;

    It works, boss.

    • unalivejoy
      link
      fedilink
      English
      4•
      edit-2
      2 years ago

      This must be a custom random function, because it’s standard for random to return a float between 0-1 exclusive. Maybe you meant to multiply by 100 instead of modulo.

      • @drolex@sopuli.xyz
        link
        fedilink
        10•2 years ago

        I think for once I didn’t fuck up.

        https://cplusplus.com/reference/cstdlib/rand/

        • @Snazz@lemmy.world
          link
          fedilink
          5•2 years ago

          You guys are talking about two different things. Random integer vs random float

Programmer Humor@lemmy.ml

!programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 762 users / day
  • 1.47K users / week
  • 3.59K users / month
  • 10.1K users / 6 months
  • 36.3K subscribers
  • 1.76K Posts
  • 38.3K Comments
  • Modlog
  • mods:
  • @AgreeableLandscape@lemmy.ml
  • @cat_programmer@lemmy.ml
  • BE: 0.19.3
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org