0

C# Module 2 (Multiple of 3) Explain please, how the program works

" 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 " Should I use the array here? My code is terrible... using System; using System.Collections.Generic; namespace SoloLearn { class Program { static void Main(string[] args) { int number = Convert.ToInt32(Console.ReadLine()); int i, arr[20]; for (i=0;i<number;i++) { if (number%3==0) {arr[i]="*";} Console.WriteLine(arr[i]); } } } }

5th Jan 2021, 11:53 AM
Anastasiia Kudria
Anastasiia Kudria - avatar
3 Respuestas
+ 2
You have an array declared incorrectly and array must be of the same data type) In addition, the array is completely optional here, see this code https://code.sololearn.com/cA340A0A1A20/?ref=app
5th Jan 2021, 6:44 PM
Merden21
Merden21 - avatar
- 1
Thank you very much guys. I got everything, I just confused with this task 👍💞
6th Jan 2021, 5:00 PM
Anastasiia Kudria
Anastasiia Kudria - avatar