0

Hi guys..! I want the output to be columns

I'm studying C#, and I've been solving a problem that only outputs odd numbers. But in your problem, you want the output to be horizontal. The code I've written now appears vertically. Can you tell me how to do it? Below is the code I wrote using System; public class sololearn { public static void Main(String[] args) { int num = Convert.ToInt32(Console.ReadLine()); // your code goes here for(int i=1; i<=num; i++) { if(i%2!=0) { Console.WriteLine(

quot;{i}"); } } } }

6th Aug 2023, 9:30 AM
김민섭
김민섭 - avatar
3 odpowiedzi
+ 2
Just write this in if condition: // Console.Write() instead of Console.WriteLine() because 'writline' prints the output in next line. Console.Write(
quot;{i} ");
6th Aug 2023, 9:46 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 1
i appreciate your help so much
6th Aug 2023, 9:51 AM
김민섭
김민섭 - avatar
+ 1
김민섭 Your welcome.
6th Aug 2023, 1:28 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar