QUICK!
WRITE A PROGRAM IN YOUR FAVORITE LANGUAGE THAT ASKS THE USERS NAME
AND AGE AND DISPLAYS THE LENGTH OF THEIR NAME AND THEIR AGE + 1
OR THIS BIRD WITH A KNIFE IS GOING TO STAB YOU!
QUICK!
Other urls found in this thread:
public static void main(String... args) {
System.out.println("what are you gonna do, stab me?");
}
plz dont hurt me
#!/usr/bin/perl -w
# script to avoid knife wounds
use strict;
print "Enter a name: ";
my $name = ;
print "Enter an age: ";
my $age = ;
$age++;
my $lenName = length $name;
print "Length of name: $lenName\nAge + 1: $age";
name = input("what do people call you?:")
age = input("for how many years have you been suffering on this ungodly earth?":)
print("your age + 1 is %s your name + 1 is %s + 1" % (float(age) + 1, name))
stab me
stab me
#!/bin/bash
echo what is name
read name
echo what is age
read age
echo name length ${#name} and age + 1 $((age + 1))
>html
come on OP this is like chapter 1 homework
if you start like this now you're never gonna make it
>QUICK DO MY HOMEWORK FOR ME IT'S DUE IN AN HOUR
Do your own work, kid. If you can't do something so fucking simple you deserve to fail your class.
>QUICK DO MY HOMEWORK GEE
>PLS
>GIMME ATTENTION
>PLS
>MY WIFE'S SON HATES ME
Thats a pretty boring one OP
Sometimes these are an interesting challenge
puts "a/s/l ?"
a,s,l = gets.chomp.split
a = a.to_i
puts a < 12 ? "oh fugg!" : a < 16 ? "wanna cs?" : "meh, too old"
>going on Sup Forums for homework answers instead of just googling it.
>"how to user input integer"
>"how to add 1 to an integer"
>"how to convert int to string"
function fuckOffBird(){
var name = prompt('Name?');
var age = prompt('Age?');
alert(name.length + parseInt(age) + 1);
}
10 PRINT "WHAT IS YOUR NAME?"
20 PRINT "THE LENGTH OF THEIR NAME AND THEIR AGE + 1"
30 END
print "just fuck my boipussy up senpai"
>5 lines of code
>And people still hate JavaScript
Can anyone beat 5 lines?
var name = prompt('Name?');
var age = prompt('Age?');
alert(name.length + parseInt(age) + 1);
>It actually could be 3 lines
var name = prompt('Name?'), age = prompt('Age?');alert(name.length + parseInt(age) + 1);
1 line
I want to say that doesn't really count. But it's probably because I'm salty.
RATE:
#!/bin/bash
age=0
agegood=0
ageask() {
echo -n "age plz in number retart: "
read age
if [ "$age" -eq "$age" ] 2>/dev/null; then
agegood=1
else
echo omg you retardo
fi
}
echo -n "name plz: "
read name
while [ $agegood -eq 0 ]; do
ageask
done
echo -n "lenth of ur name is "
echo `expr length $name`
echo -n "ur age + 1 is "
echo `expr $age + 1`
>backtickss
what the fuck are you even doing here
i.imgur.com
I like backticks, and what are you doing here when u don't even post images to an imageboard?
print(str(len(raw_input("What's your name?: "))) + "\n" + str(int(raw_input("What's your age?: ")) +1))
Underrated
This seems legit. gg mr. one liner, gg.
Now let's see if someone does it with less characters, excluding the prompt strings
what if u put nigger for age
>my $name = ;
>my $lenName = length $name;
>mfw people will actually defend these constructs
int main (int age, char *name[])
{
printf("%d %d\n", strlen(*(name+1)), age+1);
return 0;
}
It doesn't work very well if the user is less than two years old.
the fuck
It's easy! For example, if you're 20, just run it like this:
./a.out Anonymous fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizzbuzz 16 17 fizz 19 buzz
the fuck
Well you don't need the backticks with echo, do you.
echo `expr length $name`
could just be
expr length $name
Doesn't work. It gives the SUM of name.length + parseInt(age) + 1.