0

Can someone help me with multiples of 3 in C#?

Ive created a code who covers the first 3 cases but the other 2 are wrong but i dont know what is the problem

5th Jul 2021, 2:29 PM
margaritis tsapi
margaritis tsapi - avatar
17 Antworten
+ 5
margaritis tsapi Show your code.
5th Jul 2021, 2:31 PM
A͢J
A͢J - avatar
+ 2
You need to remove the increment(num++) from the first if statement. if(num%3==0) {Console.WriteLine("*"); }
5th Jul 2021, 3:16 PM
Simba
Simba - avatar
+ 2
Ok problem solved. Thank u guys for your help
5th Jul 2021, 3:28 PM
margaritis tsapi
margaritis tsapi - avatar
0
How can i do that?
5th Jul 2021, 2:36 PM
margaritis tsapi
margaritis tsapi - avatar
0
3 = (3) 3 + 3 = (6) 3 + 3 + 3 = (9) 3 + 3 + 3 + 3 = (12) find the pattern here
5th Jul 2021, 2:38 PM
minirkk
minirkk - avatar
0
Copy your code, go to playground, create a new script, paste your code in there, save it. Make it public, click the little + in this thread, select insert code, search your code, select it 👍
5th Jul 2021, 2:40 PM
Lisa
Lisa - avatar
5th Jul 2021, 2:44 PM
margaritis tsapi
margaritis tsapi - avatar
0
Your 2nd if-statement should be a else- or if-else statement
5th Jul 2021, 2:53 PM
Lisa
Lisa - avatar
0
I replaced the second if with else and now the only true is the 5th case
5th Jul 2021, 3:02 PM
margaritis tsapi
margaritis tsapi - avatar
0
the example output in the task description looks like everything needs to be in a single line. Could it be that?
5th Jul 2021, 3:07 PM
Lisa
Lisa - avatar
0
Idk what is wrong. Can u upload the correct code?
5th Jul 2021, 3:10 PM
margaritis tsapi
margaritis tsapi - avatar
0
And I just noticed that your code doesn't print e g. 4 and 7
5th Jul 2021, 3:11 PM
Lisa
Lisa - avatar
0
In the first 3 cases everything is good. I think the problem might be when number is 3,6,9,12...
5th Jul 2021, 3:14 PM
margaritis tsapi
margaritis tsapi - avatar
0
Did you study Simba s code?
5th Jul 2021, 3:15 PM
Lisa
Lisa - avatar
0
Yes right now my code is exactly as his code
5th Jul 2021, 3:18 PM
margaritis tsapi
margaritis tsapi - avatar