+ 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?
6 odpowiedzi
+ 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..
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");}}}
0
Just take care of the curly braces
0
Perfected the above code
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");
}
}
}
}