The value is stored in a
variable called a.
Then the program will show the output as seen below:
The value of a is 10.
................................
The value of ++a is 11.
The value of a is 11.
The value of a++ is 11.
The value of a is 12.
The value of --a is 11.
The value of a is 11.
The value of a-- is 11.
The value of a is 10.
Solution:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Csharp_exercises
{
class Program
{
static void Main(string[] args)
{
int a;
int b;
Console.Write("Enter a value:");
a=int.Parse(Console.ReadLine()) ;
Console.WriteLine("The value of a is {0}.",a);
b=++a;
Console.WriteLine("The value of ++a is {0}.",b);
Console.WriteLine("The value of a is {0}.",a);
b = a++;
Console.WriteLine("The value of a++ is {0}.", b);
Console.WriteLine("The value of a is {0}.", a);
b=--a;
Console.WriteLine("The value of --a is {0}.", b);
Console.WriteLine("The value of a is {0}.", a);
b=a--;
Console.WriteLine("The value of a-- is {0}.", b);
Console.WriteLine("The value of a is {0}.", a);
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Csharp_exercises
{
class Program
{
static void Main(string[] args)
{
int a;
int b;
Console.Write("Enter a value:");
a=int.Parse(Console.ReadLine()) ;
Console.WriteLine("The value of a is {0}.",a);
b=++a;
Console.WriteLine("The value of ++a is {0}.",b);
Console.WriteLine("The value of a is {0}.",a);
b = a++;
Console.WriteLine("The value of a++ is {0}.", b);
Console.WriteLine("The value of a is {0}.", a);
b=--a;
Console.WriteLine("The value of --a is {0}.", b);
Console.WriteLine("The value of a is {0}.", a);
b=a--;
Console.WriteLine("The value of a-- is {0}.", b);
Console.WriteLine("The value of a is {0}.", a);
Console.ReadLine();
}
}
}
No comments:
Post a Comment