Please can any one help me understand this code???( in the discreption) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please can any one help me understand this code???( in the discreption)

using System; using System.Collections.Generic; namespace SoloLearn { class Program { static void Main(string[] args) { int number = Convert.ToInt32(Console.ReadLine()); //your code goes here string result = ""; int i = 1 ; while ( i <= number ) { if ( i % 3 == 0 ) { result = result + '*'; } else { result = result + i.ToString(); } i++; } Console.WriteLine ( result ); } } }

25th Sep 2022, 10:32 AM
_Pythm _
2 Answers
+ 1
This code will ask for a number (since you use Convert.ToInt32) and will write a string with ascending numbers (12345...) until the number given by the user, but it will skip the number and write a * on multiples of three. Example: Input: 10 Output: 12*45*78*10
25th Sep 2022, 10:44 AM
Tomás Ribeiro
Tomás Ribeiro - avatar
+ 1
What exactly do you not understand?
25th Sep 2022, 11:48 AM
Solo
Solo - avatar