• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Who can code?
#1
I saw this on over on HF and I thought it was interesting. I will tag it on here and post my solution(in C). Let us see what you guys come up with. Here it is:

"I found this site today that says 199 out of 200 people that are applying for programming jobs today can't code anything.

So interviewers come up with questions the applicant must answer with code to prove they can solve simple problems.

Here is the question:
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

Please post your code here (language is your choice) or sit down and stop calling yourself a programmer! It should take less than 5 minutes to write."

Anyway here is mine
[spoiler]
[code=c]

#include <stdio.h>

#define LOWER 0 /*first number to count*/
#define UPPER 99 /*last number to count*/
main(){
int n;
n = LOWER;

while (n <= UPPER) {
++n;
if (n % 3 != 0 && n % 5 != 0)
printf("%d\n", n);
else if (n % 3 == 0 && n % 5 == 0)
printf("FizzBuzz\n");
else if (n % 3 == 0)
printf("Fizz\n");
else
printf("Buzz\n");
}
}
[/code]
[/spoiler]
  Reply
#2
I can't program in C, but from what I remember of VB

[spoiler][code=vb]Option Explicit
Private sub forum_main
dim whole as integer
dim count as integer
dim threeresult as double
dim fiveresult as double

<subroutine "counter">
count = 1
count = count+1
threeresult = count/3
fiveresult = count/5

If threeresult is integer
print "Fizz"
If fiveresult is integer
print "Buzz"
If threeresult is integer and fiveresult is integer
print "FizzBuzz"
else
print count
end if
</subroutine "counter">

If count <100
call counter
else
end
end if

End sub[/code][/spoiler]


I can't remember the command for creating a subroutine, but considering I haven't coded in over 2 years I've not done bad
[Image: Bulbasaur_by_bigsharn.jpg]
As you do...
  Reply
#3
Nice thread and idea, i know nothing about C, but i'll give this a whirl in python tomorrow.
  Reply
#4
The exercise is meant for ANY language. C just happens to be my personal favorite(Multix/Unix was created with it after all.) If I have like an extra hour I might even post a solution in ASM, if I am feeling particularly masochistic.
  Reply
#5
I can BB code. :8:

Bold

Years of experience. Big Grin
@PerryThePerson
Made a Twitter cause everyone bitch's on Facebook.

Twitter? U MAD
  Reply
#6
I'd quite happily learn Arduino but I don't have the patience to learn a new language
[Image: Bulbasaur_by_bigsharn.jpg]
As you do...
  Reply
#7
(03-07-2010, 06:03 AM)bigsharn Wrote: I'd quite happily learn Arduino but I don't have the patience to learn a new language

Arduino is C and C++ based. If you understand C you can do Arduino. If you only learn one language C would be the one to learn. The best book IMHO is The C Programming Language. It was written by the guys who created the language. It is clear, concise and excellent examples are given for every concept. It is only about 300 pages, and you will walk away much wiser than when you started. I read the book back in 1989 when I was around 10 but it is just as valid now as it was back then. I do have an ebook copy. PM me if interested.
  Reply
#8
Na, it's alright, I spend most of my time jobhunting, gaming and writing poetry and articles for this site
[Image: Bulbasaur_by_bigsharn.jpg]
As you do...
  Reply
#9
(04-07-2010, 10:05 AM)bigsharn Wrote: Na, it's alright, I spend most of my time jobhunting, gaming and writing poetry and articles for this site

Fair enough. I guess I am just from the old school. I am a bit obsessive compulsive about learning and so I am always pounding through some book/reference manual. I am still a gamer, but I am getting old and my hand eye isn't what it used to be unfortunately. Getting pwned by 12 year olds whose balls haven't dropped yet isn't my idea of a good time I am afraid, therefore my gaming time has dipped drastically. I own my own business which is 50% network security consulting and 50% on call technician(lately just killing tons of viruses). At night I get to do what I want to do after fixing everybody elses' shit all day, and I generally find myself coding. You are a young man and you should do what makes you tick. :thumbs

I must admit I am a bit disappointed though, I figured there would have been a few more guys who would have at least attempted this challenge. Still waiting on Mark's Python script BTW. Se la vi.
  Reply
#10
In honesty the two of us and Mark are the only one that know anything about programming; Chris and Jamie are more gamers than coders and tbh... I'm not sure about Drumm though :p
[Image: Bulbasaur_by_bigsharn.jpg]
As you do...
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [C++] Minesweeper Trainer - Source Code Clones 0 9,158 13-11-2011, 01:19 PM
Last Post: Clones

Forum Jump: