0
using System;
public class Exercise6
{
    public static void Main()
    {

    int x,y,z;

    Console.Write("First number:");
    x = Convert.ToInt32(Console.ReadLine());

    Console.Write("\nSecond number:");
    y = Convert.ToInt32(Console.ReadLine());

    Console.Write("\nThird number:");
    z = Convert.ToInt32(Console.ReadLine());

    int res1 = ((x + y) * z);
    Console.WriteLine(res1);
}

}

So I would like it if it would display "res1" on the console, but instead it just closes. How can I stop the console from closing?

SSA
  • 1

1 Answers1

0

If you add another call to Console.ReadLine(), the console window will stay open until you hit enter.

using System;
public class Exercise6
{
    public static void Main()
    {

    int x,y,z;

    Console.Write("First number:");
    x = Convert.ToInt32(Console.ReadLine());

    Console.Write("\nSecond number:");
    y = Convert.ToInt32(Console.ReadLine());

    Console.Write("\nThird number:");
    z = Convert.ToInt32(Console.ReadLine());

    int res1 = ((x + y) * z);
    Console.WriteLine(res1);
    Console.ReadLine();
}
Broom
  • 596
  • 2
  • 18