• 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


Messages In This Thread
Who can code? - by Pack3t SynAck3r - 02-07-2010, 01:22 AM

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

Forum Jump: