How to solve the C# project multiple of 3 | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 19

How to solve the C# project multiple of 3

How to Solve Multiple of 3 C# project Problem: 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 Multiples of 3 by "*" Sample Input 7 Sample Output 12*45*7 Q: Is it asking me to list the multiples of 3 from 1 to 7? Also, How the F*** can 7 turn into 12*45*7? They need to explain what they want.

16th Dec 2020, 10:46 AM
Abdul Qayom Silab🇦🇫
Abdul Qayom Silab🇦🇫 - avatar
66 ответов
- 12
Abdul Qayom Silab🇦🇫 I just completed this assignment. you have output the numbers in a line. you need to convert every multiple of 3 into * it's not asking you to print 1 to 7 digits. you just have print 1 to N(where n is the user inputting any number)
16th Dec 2020, 10:55 AM
Rellot's screwdriver
Rellot's screwdriver - avatar
+ 65
this is for everyone who is confused about how in the sample problem its input is 7 and the output includes 12 and 45 (which is obviously not between 1-7). In your program, it will not include the spaces in between the numbers. So, it isn't printing 12 and 45. It's printing 1, 2, 4, 5, 7 as numbers that are not multiples of 3 from 1-7. replacing the multiples of 3 from 1-7 with * (which are 3 and 6). That makes the output 12*45*7.
10th Jan 2021, 2:30 AM
Carson Heyman
Carson Heyman - avatar
+ 38
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 for(int i=1; i<=number; i++) { if(i % 3==0) { Console.WriteLine("*"); } else { Console.WriteLine(i); } } } } }
5th Feb 2021, 12:41 PM
Md Momin Uddin Hridoy
Md Momin Uddin Hridoy - avatar
+ 19
int number = Convert.ToInt32(Console.ReadLine()); for (int i=1;i<=number;i++) if (i%3==0) {Console.WriteLine("*"); } else { Console.WriteLine(i);}
15th Jan 2021, 7:49 PM
Павел Сергеевич
Павел Сергеевич - avatar
+ 16
Can someone tell me where the 12 and 45 are coming from
3rd Jan 2021, 1:49 AM
Abner Koffi
+ 14
i feel like this challenge is way out of line for the level of knowledge gained so far for a person new to coding. as someone new to this stuff, ive been working through this course, and up until this point, ive been able to figure out pretty much everything under my own steam. this challenge however, id have never in a hundred years been able to figure out without the use of a google search. the question is badly phrased, and even after seeing the solution, its still breaking my brain to figure it out.
25th Mar 2021, 5:17 AM
Andrew Hall
Andrew Hall - avatar
+ 13
(for i = 1; i <= number; i++) if (i%3 == 0) Print "*" else print i; Note: this is just the pseudo code not the real program, hope it helps
18th Dec 2020, 9:51 AM
Abdul Lee🎌🇳🇬
Abdul Lee🎌🇳🇬 - avatar
+ 5
Dude is really confusing 12 is twelve its 1 and 2 putting together, so it's using Write instead of WriteLine... So its 1 2 * 4 5 * 7
28th Jun 2021, 12:03 PM
Mohammed Algald
Mohammed Algald - avatar
+ 4
using System; using System.Collections.Generic; namespace SoloLearn { class Program { static void Main(string[] args) { int number = Convert.ToInt32(Console.ReadLine()); for(int i=1;i<=number;i++){ Console.Write((i%3==0)?"*":Convert.ToString(i)); } } } }
10th Feb 2022, 4:30 PM
Erman Konyar
Erman Konyar - avatar
+ 3
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 for(int i=1; i<=number; i++) { if(i % 3==0) { Console.WriteLine("*"); } else { Console.WriteLine(i); } } } } } Urraaaaaa!!!!!
27th Jan 2021, 3:26 PM
Kelvyn Eleazar De Oleo Taveras
Kelvyn Eleazar De Oleo Taveras - avatar
+ 3
Can also use while loop namespace SoloLearn { class Program { static void Main(string[] args) { int number = Convert.ToInt32(Console.ReadLine()); //your code goes here int count = 0; while (count < number) { count++; if (count % 3 == 0) { Console.Write("*"); } else { Console.Write(count); } } } } }
19th Jun 2021, 7:24 PM
Sören Blocksdorf
Sören Blocksdorf - avatar
+ 3
use Console.Write(); instead of : Console.WriteLine(); in order to align the output in one line ... Good Luck . //your code goes here for (int i = 1; i <= number; i++) { if (i % 3 == 0) { Console.Write("*"); } else { Console.Write(i); } }
23rd Aug 2021, 8:57 AM
Mahdi Saeedi
Mahdi Saeedi - avatar
+ 2
int i; Console.WriteLine(“Enter a number=“); int number = Convert.ToInt32(Console.ReadLine()); for(i=1;i<=number;i++){ if(i%3==0) Console.Write(“*”); else Console.Write(i); }
31st Aug 2021, 8:15 AM
Nimnadi Sooriyabandara
Nimnadi Sooriyabandara - avatar
+ 2
Don't use Console.WriteLine since you want it on the same line instead use Console.Write int number = Convert.ToInt32(Console.ReadLine()); for(int x = 1; x <= number; x++) if (x % 3 == 0) { Console.Write("*"); } else { Console.Write(x); }
4th Aug 2022, 12:13 AM
Onanuga Benjamin
+ 1
startNumber++ in the loop, <= condition. also handle what you should print if the condition is not true. use Write() to print in a single line without going to next line after printing MrDevEzeoke
16th Dec 2020, 1:30 PM
Flash
+ 1
it was cofusing that SL didn't clarified the type of output data. Outputs can be ints and * char line by line in console, no need to convert all in one line string.
16th Jan 2021, 7:10 PM
John Code
+ 1
Ugh. This is so confusing when you look at it at face value. Count from 1 to the Input number. Maybe write it down on a notebook. Then compare the numbers you wrote to what the output is asking. Look for similarities. It's obnoxiously simple of an answer. If you still don't get it, pretend the asterisk is a censor.
8th Aug 2021, 8:31 PM
Donnel Waddle Dee
Donnel Waddle Dee - avatar