473,385 Members | 1,325 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

FizzBuzz Question

Hi,

I'm new to C# and won't lie, I'm finding it rather hard after not coding for a couple of years (previous experience being Python and HTML). My first assignment for the Computer Science degree I've just embarked upon is FizzBuzz which although is generally easy as it would appear with a google, it's also got some extra bools and intergers thrown in which I'm not entirely sure what to do with.

If anybody can point me in the right direction with my code it'd be greatly appreciated.

Expand|Select|Wrap|Line Numbers
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. {
  8.  
  9. namespace Fizzbuzz
  10.   {
  11.     class Program
  12.  
  13.         static void Main(string[] args)
  14.         {
  15.             for (int i = 1; i <= 100; i++)
  16.  
  17.  
  18.                  if (i % 3 == 0) Console.Write("Fizz");
  19.                  if (i % 5 == 0) Console.Write("Buzz");
  20.                  if (Console.CursorLeft == 0) Console.Write(i);
  21.  
  22.     if (i)
  23.     {   
  24.         public bool IsFizz(int input); 
  25.         public bool IsBuzz(int input); 
  26.         public bool IsFizzBuzz(int input); 
  27.         public bool IsPrime(int input);
  28.     } 
  29.     {       
  30.         public void BeginTesting() 
  31.         public int TotalFizz()
  32.         public int TotalBuzz()
  33.         public int TotalFizzBuzz()
  34.         public int TotalPrime()
  35.     }
  36.                 Console.WriteLine();
  37.  
  38.             Console.ReadLine();         
  39.         }
  40.   }
  41. }
  42.  
  43.  
Oct 17 '13 #1
1 1751
Joseph Martell
198 Expert 128KB
There seem to be a lot of errors that I can see in the code. In fact, your code does not compile in my VS 2008 environment.

If you have posted a code fragment then I would suggest you post in separate code tags so that we can look at individual questions, one at a time.

If this is your complete code, then there are a lot of things to take care of before it will compile. I would suggest starting with this code as a base (note the curly brace placement):

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Fizzbuzz  
  8. {
  9.     class Program
  10.     {     
  11.         static void Main(string[] args)
  12.         {
  13.             for (int i = 1; i <= 100; i++)
  14.             {
  15.                 if (i % 3 == 0) Console.Write("Fizz");
  16.                 if (i % 5 == 0) Console.Write("Buzz");
  17.                 if (Console.CursorLeft == 0) Console.Write(i);
  18.             }
  19.         }
  20.     }
  21. }
  22.  
From here, tackle a single goal at a time and don't move on until you have completed your goal and your code compiles without error. The last thing you want are compounding errors, especially when learning a new environment/language/etc.

Give us some more information and we would be happy to help.
Oct 22 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
35
by: globalrev | last post by:
http://reddit.com/r/programming/info/18td4/comments claims people take a lot of time to write a simple program like this: "Write a program that prints the numbers from 1 to 100. But for...
0
by: Sells, Fred | last post by:
or for i in range(1,100): print ('fizz','','') + ('buzz','','','','') or i
6
semanticnotion
by: semanticnotion | last post by:
Hi sir i want to transform the data of one table into another through foreign key but the following error come to my browser Here is my code and data base structure. CREATE TABLE IF NOT...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.