Login to ZARP
Username: Password: Remember me

TOPIC: Need help for a assignment for Coding C#

Need help for a assignment for Coding C# 5 years 1 month ago #1168963

Its not urgent but I am having issues, I am currently learning how to code C#.
My exercise is to write a program that draws a triangle of numbers from 1 to Max (chosen by the user, Max
must be a positive number) with for each of them the numbers that precede them (up to 1).

Please don't call me stupid when I am about to show the program that I done:

{
Console.WriteLine("Jusqu'a quel nombre?");
nb1 = Convert.ToInt32(Console.ReadLine());
for (i = nb1; i <= nb1; i = nb1 - 1 )
{
for (f = 1; i <= f; f++)
{
Console.Write(nb1);
}
Console.Write("\n");
}
}

I know this is hella wrong, but I am learning.
If you are good at coding C# it would be nice that you explain to me. That would be epic.
  • PoseidonEUW
  • PoseidonEUW's Avatar
  • Offline
  • Junior Boarder
  • My Mom doesn't want anyone to know who I am :(
  • Posts: 170
  • Thanks received: 29
  • Karma: -5
The topic has been locked.

Need help for a assignment for Coding C# 5 years 1 month ago #1168965

@Deadmonstor
  • narexa
  • narexa's Avatar
  • Offline
  • Divine Boarder
  • ZARP VIP Golden Blue Badge
  • Posts: 8287
  • Thanks received: 4844
  • Karma: 252
The topic has been locked.

Need help for a assignment for Coding C# 5 years 1 month ago #1168966

I think this is what you're trying to do
using System;

namespace NumberTriangle
{
    class Program
    {
        static void Main(string[] args)
        {
            
            Console.Write("Max Number: ");
            int max = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i <= max; i++)
            {
                if (i == max) { break; }
                else
                {
                    for (int f = 0; f < i; f++)
                    {
                        Console.Write(i);
                    }
                    Console.Write("\n");
                }
            }
            Console.ReadLine();
        }
    }
}
  • bunnyslippers69
  • bunnyslippers69's Avatar
  • Offline
  • Diamond Boarder
  • ZARP VIP Golden Blue Badge
  • Posts: 3539
  • Thanks received: 1185
  • Karma: 0
Last Edit: 5 years 1 month ago by bunnyslippers69.
The topic has been locked.
The following user(s) said Thank You: PoseidonEUW

Need help for a assignment for Coding C# 5 years 1 month ago #1168992

Thanks man! Really appreciate it. I will give you a thumbs up right now
  • PoseidonEUW
  • PoseidonEUW's Avatar
  • Offline
  • Junior Boarder
  • My Mom doesn't want anyone to know who I am :(
  • Posts: 170
  • Thanks received: 29
  • Karma: -5
The topic has been locked.

Need help for a assignment for Coding C# 5 years 1 month ago #1168993

You can close this post ^_^.
  • PoseidonEUW
  • PoseidonEUW's Avatar
  • Offline
  • Junior Boarder
  • My Mom doesn't want anyone to know who I am :(
  • Posts: 170
  • Thanks received: 29
  • Karma: -5
The topic has been locked.
Time to create page: 0.091 seconds

143 PLAYERS ONLINE

Connect to server View Gametracker DarkRP 1
4/127
online
Connect to server View Gametracker Deathrun
0/40
online
Connect to server View Gametracker TTT
0/47
online
Connect to server View Gametracker Bhop
0/32
online
Connect to server View Gametracker Surf
0/32
online
Connect to server View Gametracker Prop Hunt
0/42
online
Connect to server View Gametracker Sandbox
0/42
online
Connect to server Discord
139/910
online
Top