C# lesson 14 | Sololearn: Learn to code for FREE!

+1

C# lesson 14

Hi everyone, I'm doing the practice for lesson 14 I'm doing exactly the lesson said but still can't run So would you guy help me to check if anything wrong with my coding Thank you

c#

9/26/2021 12:32:58 PM

Tim Tam

17 Answers

New Answer

+3

Tim Tam You didn't assign input to variable num Also break is missing in 3rd case

+2

Tim Tam int num = Convert.ToInt32(Console.ReadLine());

+2

Tim Tam You have written complete code and still didn't get how to take input? You need to go through lesson again and check my previous reply. Just copy that line and put in your code

+1

num is what you take as input, it is not a fixed value

+1

Nakul Pasi S/O KrishnaLal Pasi This does not seem to be related to the thread's topic. Your code looks like some cpp. If you have a problem with your code, please create a new thread to get help

0

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int num = 1; Convert.ToInt32(Console.ReadLine()); /* 1 - Sports 2 - Politics 3 - Business 4 - Technology 5 - Art */ //your code goes here switch(num) { case 1: Console.WriteLine("Sports"); break; case 2: Console.WriteLine("Politics"); break; case 3: Console.WriteLine("Business"); case 4: Console.WriteLine("Technology"); break; case 5: Console.WriteLine("Art"); break; } } } }

0

Oh thank you so much but how to input to variable number AJ

0

https://code.sololearn.com/c6yNVg8M0F1s/?ref=app

0

Iam so stupid, I still don't get it AJ

0

Yes I put Int num = 3; So it is not how to input the variable right?

0

num is not 3 as in your code, num is what Convert.ToInt32... You need to save this input in num

0

num is user input, its value depends on what the users inputs as number – that's what is Console.ReadLine for

0

Sorry guys I have the problem in the lesson 5, so I will learn again Thank you so much guys

0

Hi guy I really don't understand the lesson 5 I can't input the age for this

0

https://code.sololearn.com/c09mO61aELzj/?ref=app

0

You just run the code, a input window opens, you type a number, submit and check the output

0

Oh thank you so much Lisa