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

1st Sep 2021, 12:36 PM
Павел Петров
Павел Петров - avatar
5 ответов
+ 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); }
1st Sep 2021, 1:26 PM
Tim
Tim - avatar
+ 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)
1st Sep 2021, 12:40 PM
Abhay
Abhay - avatar
+ 1
Павел Петров Post your code here
1st Sep 2021, 2:50 PM
Atul [Inactive]
0
25th Aug 2022, 9:58 PM
Mohannad Abudagga
Mohannad Abudagga - avatar
0
what is the code 23 code project ? thanks .
25th Aug 2022, 10:00 PM
Mohannad Abudagga
Mohannad Abudagga - avatar