this is the code for my first little application
{ class Program
{ static void Main(string[] args)
{ start: Random numbergen = new Random(); // random num generator
int a = numbergen.Next(2, 16); //used for 1st random number
int b = numbergen.Next(2, 10); //used for 2nd random number
int symbol = numbergen.Next(1, 5); // used for changing symbol
float ans;
Console.WriteLine("\t\t\tI.Q TEST\n\n"); // Heading
switch (symbol) {
case 1:
Console.WriteLine("\tQ1:Solve the question\n " + a + "\nx " + b + " ?"); ans = a * b; break;
case 2:
Console.WriteLine("\tQ1:Solve the question\n " + a + "\n- " + b + " ?"); ans = a - b; break;
case 3: Console.WriteLine("\tQ1:Solve the question\n " + a + "\n% " + b + " ?"); ans = a / b;
break;
case 4: Console.WriteLine("\tQ1:Solve the question\n " + a + "\n+ " + b + " ?"); ans = a + b;
break;
default:
Console.WriteLine("\t\tSolve the question\n " + a + "\n+ " + b + " ?");
ans = a + b;
break; }
float answer = Convert.ToInt32(Console.ReadLine());
if (answer == ans) {
Console.WriteLine("Correct");
Console.WriteLine("\n\t\t\tpress 1 to continue\n\n"); }
else {
int diffrespond = numbergen.Next(1, 4);
switch (diffrespond) {
case 1: Console.WriteLine("False");
Console.WriteLine("Answer was\t" + ans + "");
break;
case 2: Console.WriteLine("Negative!");
Console.WriteLine("Answer was\t" + ans + "");
break;
default: Console.WriteLine("Wrong Answer");
Console.WriteLine("Answer was\t" + ans + "");
break;
}
Console.WriteLine("\n\t\t\tpress 1 to continue\n\n"); }
int restart = Convert.ToInt32(Console.ReadLine());
if (restart== 1) { goto start; } } }}
subscribe for more :-)