0

# Can anyone HELP with 23 Code Project C#

You are an elementary school teacher and explaining multiplication to students. You are going to use multiplication by 3 as your example. The program you are given takes N number as input. Write a program to output all numbers from 1 to N, replacing all numbers that are multiples of 3 by "*". Sample Input 7 Sample Output 12*45*7

5 Antworten

+ 3

Try StringBuilder, the string looks like it needs to be updated multiple times, here's the solution if you're desperate for one:
using System;
using System.Text;
static void Main()
{
StringBuilder sb = new StringBuilder();
int input = int.Parse(Console.ReadLine());
for (int i = 1; i <= input; i++)
{
if (i % 3 == 0)
{
sb.Append("*");
}
else
{
sb.Append(i);
}
}
Console.WriteLine(sb);
}

+ 3

What code have you written so far ? You can simply use a for loop to loop over 1 to N numbers and then if else to check which one is multiple of 3 (for example if 6%3==0 , 6 is multiple of 3)

+ 1

Павел Петров Post your code here

0

0

what is the code 23 code project ?
thanks .