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 Answers
+ 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