New course! Every coder should learn Generative AI!
+ 1

# C sharp loop questions

If i write a loop where a user inputs 5 marks hoe can i write then an if statement saying that if two of those marks are less than 50 he failed?

10th Nov 2018, 11:05 AM
Sahan Edirisooriya
+ 3
Try this.. for (int i=0;i<5;i++){ int x=Convert.ToInt32(Console.ReadLine()); if (x<50){ Console.WriteLine("You failed"); } } You should complete the c# coarse all you need is covered in it..
10th Nov 2018, 11:28 AM
Mensch
10th Nov 2018, 11:53 AM
Danijel Ivanović
0
using System; namespace solved{ class Program{ public static void Main(string[] args){ int Times = 0; for (int I=0;I<5;I++){ int input = Convert.ToInt64(Console.ReadLine()); if (input<50){ times += 1;}} if (Times>=2){ Console.WriteLine("Failed");}}}
22nd May 2021, 1:54 PM
Eashan Morajkar
0
Just take care of the curly braces
22nd May 2021, 1:54 PM
Eashan Morajkar
0
Perfected the above code
23rd May 2021, 4:46 AM
Eashan Morajkar
0
using System; namespace solved { public static class Program { public static void Main() { int times = 0; for(int i=0;i<5;i++){ int input = Convert.ToInt32(Console.ReadLine()); if (input<50){ times += 1; } } if (times>=2){ Console.WriteLine("Failed"); }else{ Console.WriteLine("Passed"); } } } }
23rd May 2021, 4:46 AM
Eashan Morajkar