0

ماحل المشكلة التالية؟ وما الخطأ في كودي؟

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 "*".

22nd Jun 2022, 10:52 AM
Zina Shekh Alzoor
Zina Shekh Alzoor - avatar
2 Answers
+ 3
Zina Shekh Alzoor You have to print i and check i % 3 == 0 You didn't use else so everytime same number will be print You have to write if (i % 3 == 0) //print * else //print i
22nd Jun 2022, 3:37 PM
A͢J
A͢J - avatar
0
static void Main(string[] args) { int number = Convert.ToInt32(Console.ReadLine()); //your code goes here { for (int i=1;i<=number;i++) { if(number%3==0) { Console.Write("*"); } Console.Write (number); }
22nd Jun 2022, 10:53 AM
Zina Shekh Alzoor
Zina Shekh Alzoor - avatar