٣٣ مسئلة برمجة

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

‫‪ (1‬ﺣﺩﺩ ﺃﻱ ﻣﻥ ﻫﺫﻩ ﺍﻟﺗﺳﻣﻳﺎﺕ ﺻﺣﻳﺢ ﻛﺗﺳﻣﻳﺔ ﻟﻣﺗﺣﻭﻻﺕ ؟ ﻣﻊ ﺫﻛﺭ ﺍﻟﺳﺑﺏ‬

‫‪_name, num of mark, else, 1number, flag, degree>4, %age, test1‬‬

‫‪ (2‬ﺍﻛﺗﺏ ﺧﻭﺍﺭﺯﻣﻳﺔ ) ﺑﺎﻟﻁﺭﻳﻘﺔ ﺍﻟﻧﺻﻳﺔ ﺍﻟﺑﻳﺎﻧﻳﺔ( ﺗﻘﻭﻡ ﺑﺈﺩﺧﺎﻝ ﺭﻗﻡ ﺻﺣﻳﺢ ﻭﺛﻡ ﻁﺑﺎﻋﺔ ﺍﻷﺭﻗﺎﻡ ﻣﻥ ‪ 1‬ﻭﺣﺗﻰ‬
‫ﻫﺫﺍ ﺍﻟﺭﻗﻡ ؟ ) ﻣﺛﺎﻝ ﻳﺩﺧﻝ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺭﻗﻡ ‪ 5‬ﻓﻳﻁﺑﻊ ﺍﻟﺑﺭﻧﺎﻣﺞ ﺍﻷﺭﻗﺎﻡ ‪.(5-4-3-2-1‬‬

‫ﺍﻟﺑﺩﺍﻳﺔ‬ ‫‪.1‬‬
‫ﺍﺣﺟﺯ ﻣﻛﺎﻥ ﻓﻲ ﺍﻟﺫﺍﻛﺭﺓ ﻟﺭﻗﻡ‬ ‫‪.2‬‬
‫ﺻﺣﻳﺢ ﺑﺎﺳﻡ ‪N‬‬
‫ﺍﻗﺭﺃ ‪N‬‬ ‫‪.3‬‬
‫ﻁﺎﻟﻣﺎ )‪(N>0‬‬ ‫‪.4‬‬
‫‪ .a‬ﺍﻁﺑﻊ ‪N‬‬
‫‪N=N-1 .b‬‬
‫ﺍﻟﻧﻬﺎﻳﺔ‬ ‫‪.5‬‬

‫‪ (3‬ﻣﺎ ﻫﻭ ﺧﺭﺝ ﺍﻟﺑﺭﻧﺎﻣﺞ ﺍﻟﺗﺎﻟﻲ ؟‬


Console.WriteLine("names\tage\n");
Console.WriteLine("maher\t18");
Console.WriteLine("majed\t20");
int result = 80;
string degree = "excellent";
Console.WriteLine("your result is {1}, {0}%",result,degree);

‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ً ﻳﻘﻭﻡ ﺑﺈﺩﺧﺎﻝ ﻗﻳﻣﺗﻳﻥ ﻋﺩﺩﻳﺗﻳﻥ ﻣﻥ ﺍﻟﻧﻭﻉ ﺍﻟﺻﺣﻳﺢ ﻭﺣﻔﻅﻬﻣﺎ ﺿﻣﻥ ﻣﺗﺣﻭﻟﻳﻥ ﻣﻧﺎﺳﺑﻳﻥ ﺛﻡ‬4
‫ﺇﺟﺭﺍء ﺗﺑﺩﻳﻝ ﻗﻳﻣﺗﻲ ﺍﻟﻣﺗﺣﻭﻟﻳﻥ ﻓﻳﻣﺎ ﺑﻳﻧﻬﻣﺎ؟‬
static void Main(string[] args)
{
//declaring variables
int x,y,temp;
//entering variables
Console.WriteLine("Enter x:");
x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter y:");
y = Convert.ToInt32(Console.ReadLine());
//swaping
temp = x;
x= y;
y = temp;
//printing
Console.WriteLine("x={0} ,y={1}",x,y);
}
‫ ﺑﺎﻹﺿﺎﻓﺔ‬.‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻘﻭﻡ ﺑﺈﺩﺧﺎﻝ ﻋﺩﺩﻳﻥ ﺣﻘﻳﻘﻳﻥ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺛﻡ ﻁﺑﺎﻋﺔ ﺍﻟﻌﻣﻠﻳﺎﺕ ﺍﻟﺣﺳﺎﺑﻳﺔ ﺑﻳﻧﻬﻣﺎ‬5
:‫ﻟﻌﻣﻠﻳﺎﺕ ﺍﻟﻣﻘﺎﺭﻧﺔ ﻛﺎﻟﺗﺎﻟﻲ‬

static void Main(string[] args)


{
double x, y;
Console.WriteLine("please enter the first number");
x = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("please enter the second number");
y = Convert.ToDouble(Console.ReadLine());

Console.WriteLine("{0} + {1} ={2}",x,y,x+y);


Console.WriteLine("{0} - {1} ={2}", x, y, x - y);
Console.WriteLine("{0} * {1} ={2}", x, y, x * y);
Console.WriteLine("{0} / {1} ={2}", x, y, x / y);
Console.WriteLine("{0} % {1} ={2}", x, y, x % y);
Console.WriteLine("{0} == {1} ={2}", x, y, x == y);
Console.WriteLine("{0} != {1} ={2}", x, y, x != y);
Console.WriteLine("{0} > {1} ={2}", x, y, x > y);
Console.WriteLine("{0} >= {1} ={2}", x, y, x >= y);
Console.WriteLine("{0} < {1} ={2}", x, y, x < y);
Console.WriteLine("{0} <= {1} ={2}", x, y, x <= y);
}
.‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻘﻭﻡ ﺑﺈﺩﺧﺎﻝ ﻗﻳﻣﺗﻳﻥ ﺑﻭﻟﻳﺎﻧﻳﺗﻳﻥ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺛﻡ ﻁﺑﺎﻋﺔ ﺍﻟﻌﻣﻠﻳﺎﺕ ﺍﻟﻣﻧﻁﻘﻳﺔ ﺑﻳﻧﻬﻣﺎ‬6
static void Main(string[] args)
{
bool x, y;
Console.WriteLine("Enter first bool");
x = Convert.ToBoolean(Console.ReadLine());
Console.WriteLine("Enter second bool");
y = Convert.ToBoolean(Console.ReadLine());

Console.WriteLine("the and operation between {0} ,{1} is {2}", x, y, x & y);


Console.WriteLine("the or operation between {0} ,{1} is {2}", x, y, x | y);
Console.WriteLine("the xor operation between {0} ,{1} is {2}", x, y, x ^ y);
Console.WriteLine("the not operation {0} ,{1} is {2} , {3}", x, y, !x, !y);
}
‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻘﻭﻡ ﺑﺈﺩﺧﺎﻝ ﺍﺳﻡ ﺍﻟﻣﺳﺗﺧﺩﻡ ﻭﻋﻣﺭﻩ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ ﺭﺳﺎﻟﺔ ﺗﺭﺣﻳﺑﻳﺔ ﻛﺎﻟﺗﺎﻟﻲ‬7

static void Main(string[] args)


{
string name;int age;
Console.WriteLine("enter your name:");
name = Console.ReadLine();
Console.WriteLine("Enter you age");
age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Hello \"{0}\". you are {1} years old.",name,age);
}
.‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺞ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﻧﺻﻑ ﻗﻁﺭ ﺍﻟﺩﺍﺋﺭﺓ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ ﻣﺳﺎﺣﺗﻬﺎ ﻭﻣﺣﻳﻁﻬﺎ‬8

static void Main(string[] args)


{
Console.WriteLine("enter half of the radius");
int r = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("the circle circumference {0}", 2*3.14*r);
Console.WriteLine("the circle area is {0}",3.14*r*r);
}
.‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺞ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﻁﻭﻝ ﻭﻋﺭﺽ ﺍﻟﻣﺳﺗﻁﻳﻝ ﺛﻡ ﻳﻘﻭﻡ ﺑﻁﺑﺎﻋﺔ ﻣﺳﺎﺣﺗﻪ ﻭﻣﺣﻳﻁﻪ‬9

static void Main(string[] args)


{
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Red;
Console.Clear();

Console.WriteLine("enter the x");


int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter the y");
int y = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("The rectangular area is {0}", x*y);
Console.WriteLine("The rectangular perimeter {0}", 2*(x+y));
}
.‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺞ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺭﻗﻡ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ ﺟﺩﻭﻝ ﺍﻟﺿﺭﺏ ﺍﻟﺧﺎﺹ ﺑﻬﺫﺍ ﺍﻟﺭﻗﻡ‬10

static void Main(string[] args)


{
Console.Write("enter number :");
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("{0}*{1}={2}", x, 0, x * 0);
Console.WriteLine("{0}*{1}={2}", x, 1, x * 1);
Console.WriteLine("{0}*{1}={2}", x, 2, x * 2);
Console.WriteLine("{0}*{1}={2}", x, 3, x * 3);
Console.WriteLine("{0}*{1}={2}", x, 4, x * 4);
Console.WriteLine("{0}*{1}={2}", x, 5, x * 5);
Console.WriteLine("{0}*{1}={2}", x, 6, x * 6);
Console.WriteLine("{0}*{1}={2}", x, 7, x * 7);
Console.WriteLine("{0}*{1}={2}", x, 8, x * 8);
Console.WriteLine("{0}*{1}={2}", x, 9, x * 9);
Console.WriteLine("{0}*{1}={2}", x, 10, x * 10);
}
.‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺧﻣﺳﺔ ﺃﺭﻗﺎﻡ ﺻﺣﻳﺣﺔ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ ﺍﻟﻣﺗﻭﺳﻁ ﺍﻟﺣﺳﺎﺑﻲ ﻟﻬﺎ‬11

static void Main(string[] args)


{
Console.WriteLine("enter the four numbers");
int x = Convert.ToInt32(Console.ReadLine());
int y = Convert.ToInt32(Console.ReadLine());
int z = Convert.ToInt32(Console.ReadLine());
int f = Convert.ToInt32(Console.ReadLine());
int g = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("the avarege is {0}", (x + y + z + f + g) / 5);
}
‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺞ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﻣﺣﺭﻑ ﻭﻳﻁﺑﻊ ﻟﻪ ﻣﺷﺗﻁﻳﻝ ﻣﻥ ﺛﻼﺛﺔ ﺃﻋﻣﺩﺓ ﻭﺧﻣﺳﺔ ﺃﺳﻁﺭ ﻣﻥ‬12
:‫ﻫﺫﺍ ﺍﻟﻣﺣﺭﻑ ﻛﺎﻟﺗﺎﻟﻲ‬
static void Main(string[] args)
{
Console.WriteLine("enter the char");
char x = Convert.ToChar(Console.ReadLine()); 
Console.WriteLine("{0} {0} {0}\n{0} {0}\n{0} {0}\n{0} {0}\n{0} {0} {0}", x);
}
‫ ﺇﺫﺍ ﻛﺎﻥ ﺍﻟﺭﻗﻡ ﻳﻧﺗﻣﻲ ﺇﻟﻰ ﺍﻟﻣﺟﺎﻝ‬true ‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﺳﻣﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺭﻗﻡ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ‬13
.if ‫ ﺑﺩﻭﻥ‬false ‫[ ﻭﺇﻻ ﻳﻁﺑﻊ ﻟﻪ‬20,100]

static void Main(string[] args)


{
Console.WriteLine("enter the number");
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(x >= 20 & x <= 100);
}
‫ ﺃﻭ ﻣﻥ‬3 ‫ ﺇﺫﺍ ﻛﺎﻥ ﺍﻟﺭﻗﻡ ﻣﻥ ﻣﺿﺎﻋﻔﺎﺕ‬true ‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﺳﻣﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺭﻗﻡ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ‬14
.if ‫ ﺑﺩﻭﻥ‬false ‫ ﻭﺇﻻ ﻳﻁﺑﻊ ﻟﻪ‬7 ‫ﻣﺿﺎﻋﻔﺎﺕ‬

static void Main(string[] args)


{
Console.WriteLine("enter the number");
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(x % 3 == 0 | x % 7 == 0);
}
‫ ﺇﺫﺍ ﻛﺎﻥ ﺃﺣﺩ ﺍﻟﺭﻗﻣﻳﻥ‬true ‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﺳﻣﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺭﻗﻣﻳﻥ ﺻﺣﻳﺣﻳﻥ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ‬15
.if ‫ ﺑﺩﻭﻥ‬false ‫ ﻭﺇﻻ ﻳﻁﺑﻊ ﻟﻪ‬200 ‫ ﻭﺍﻟﺛﺎﻧﻲ ﺃﻛﺑﺭ ﻣﻥ‬100 ‫ﺃﺻﻐﺭ ﻣﻥ‬
static void Main(string[] args)
{
Console.WriteLine("enter the first number");
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter the second number");
int y = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(x < 100 && y > 200 || y < 100 && y > 200);
}

‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺛﻼﺛﺔ ﺃﺭﻗﺎﻡ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ ﺍﻟﺭﻗﻡ ﺍﻷﻛﺑﺭ ﺑﻳﻥ ﺍﻷﺭﻗﺎﻡ ﺍﻟﻣﺩﺧﻠﺔ‬16

static void Main(string[] args)


{
Console.WriteLine("enter three number");
int x = Convert.ToInt32(Console.ReadLine());
int y = Convert.ToInt32(Console.ReadLine());
int z = Convert.ToInt32(Console.ReadLine());
int largest = x;
if (y > largest)
largest = y;
if (z > largest)
largest = z;
Console.WriteLine("the largest numbers is " + largest);
}
static void Main(string[] args)
{
Console.WriteLine("enter three number");
int x = Convert.ToInt32(Console.ReadLine());
int y = Convert.ToInt32(Console.ReadLine());
int z = Convert.ToInt32(Console.ReadLine());
if (x>y && x>z)
Console.WriteLine("the largest numbers is " + x);
else if (y > x && y > z)
Console.WriteLine("the largest numbers is " + y);
else
Console.WriteLine("the largest numbers is " + z);
}
static void Main(string[] args)
{
Console.WriteLine("enter three number");
int x = Convert.ToInt32(Console.ReadLine());
int y = Convert.ToInt32(Console.ReadLine());
int z = Convert.ToInt32(Console.ReadLine());
if (x > y)
if (x > z)
Console.WriteLine("the largest numbers is " + x);
else
Console.WriteLine("the largest numbers is " + z);
else
if (y > z)
Console.WriteLine("the largest numbers is " + y);
else
Console.WriteLine("the largest numbers is " + z);
}
‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺞ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﻋﻣﻠﻳﺔ ﺣﺳﺎﺑﻳﺔ )ﺟﻣﻊ ﺃﻭ ﻁﺭﺡ ﺃﻭ ﺿﺭﺏ ﺍﻭ ﻗﺳﻣﺔ ( ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ‬17
.‫ﻧﺎﺗﺞ ﺍﻟﻌﻣﻠﻳﺔ‬

static void Main(string[] args)


{
int a = Convert.ToInt32(Console.ReadLine());
char op = Convert.ToChar(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine());

if (op == '+')
Console.WriteLine(a + " + " + b + " = " + (a + b));
else if (op == '-')
Console.WriteLine(a + " - " + b + " = " + (a - b));
else if (op == '*')
Console.WriteLine(a + " * " + b + " = " + (a * b));
else if (op == '/')
Console.WriteLine(a + " / " + b + " = " + (a / b));
else
Console.WriteLine("Wrong!.....");

}
‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺞ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺭﻗﻡ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ ﻫﻝ ﻫﻭ ﺯﻭﺟﻲ ﺃﻭ ﻓﺭﺩﻱ‬18
static void Main(string[] args)
{
Console.WriteLine("enter three number");
int x = Convert.ToInt32(Console.ReadLine());
if (x %2 == 0)
Console.WriteLine("even");
else
Console.WriteLine("odd");
}
.‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺞ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺭﻗﻡ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ ﻫﻝ ﻫﻭ ﻣﻭﺟﺏ ﺃﻭ ﺳﺎﻟﺏ ﺃﻭ ﺻﻔﺭ‬19

static void Main(string[] args)


{
Console.WriteLine("enter three number");
int x = Convert.ToInt32(Console.ReadLine());
if (x > 0)
Console.WriteLine("positive");
else if (x<0)
Console.WriteLine("negative");
else
Console.WriteLine("zero");
}
.‫ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺭﻗﻡ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ ﻣﺟﻣﻭﻉ ﺧﺎﻧﺎﺗﻪ‬ (20

static void Main(string[] args)


{
Console.WriteLine("enter the number");
int x = Convert.ToInt32(Console.ReadLine());
int sum = 0;
do
{
sum += x % 10;
x /= 10;
}
while (x / 10.0 != 0);
Console.WriteLine(sum);
}
.‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺭﻗﻡ ﺛﻡ ﻳﻁﺑﻊ ﻟﻪ ﻣﻌﻛﻭﺳﻪ‬21

static void Main(string[] args)


{
Console.WriteLine("enter the number");
int x = Convert.ToInt32(Console.ReadLine());
string reverse="";
do
{
reverse += x % 10;
x /= 10;
}
while (x / 10.0 !=0);
Console.WriteLine(reverse);
}
‫ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺭﻗﻡ ﺛﻡ ﻳﻘﻭﻡ ﺑﺣﺳﺎﺏ ﻋﺩﺩ ﺍﻟﻭﺍﺣﺩﺍﺕ ﻓﻲ ﺍﻟﺭﻗﻡ ﺍﻟﻣﺩﺧﻝ‬ (22

static void Main(string[] args)


{
Console.WriteLine("enter the number");
int x = Convert.ToInt32(Console.ReadLine());
int sum = 0;
while(x / 10.0 != 0)
{
if (x % 10 == 1)
sum++;
x /= 10;
}
Console.WriteLine(sum);
}
‫ ﻋﻧﺩ ﺍﻻﻧﺗﻬﺎء‬0 ‫ ) ﺍﻟﻣﺳﺗﺧﺩﻡ ﻳﺩﺧﻝ‬.‫ ﻋﺩﺩ ﻭﺣﺳﺎﺏ ﻣﺗﻭﺳﻁ ﺍﻷﻋﺩﺍﺩ ﺍﻟ ُﻣﺩﺧﻠﺔ‬N ‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺞ ﻹﺩﺧﺎﻝ‬23
.(‫ﻣﻥ ﺇﺩﺧﺎﻝ ﺍﻷﺭﻗﺎﻡ‬

static void Main(string[] args)


{
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Red;
Console.Clear();
Console.WriteLine("enter the number");
int x ;
double sum = 0;
int count = 0;
do
{
x = Convert.ToInt32(Console.ReadLine());
sum += x;
count++;
}
while (x != 0);

Console.WriteLine(sum/(count-1));
}
!N ‫ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺞ ﻟﺣﺳﺎﺏ‬ (24

static void Main(string[] args)


{
while (true)
{
Console.WriteLine("enter the number");
int x = Convert.ToInt32(Console.ReadLine());
int nFactorial = 1;
for (; x != 0; x--)
{
nFactorial *= x;
}
Console.WriteLine(nFactorial);
}

}
(‫ ﺭﻗﻡ ﻳﺩﺧﻠﻪ ﺍﻟﻣﺳﺗﺧﺩﻡ‬N) .N ‫ ﺍﻝ‬1 ‫ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺞ ﻟﺣﺳﺎﺏ ﻣﺟﻣﻭﻉ ﺍﻷﻋﺩﺍﺩ ﺍﻟﻔﺭﺩﻳﺔ ﻣﻥ‬ (25

static void Main(string[] args)


{
while (true)
{
Console.WriteLine("enter the number");
int N = Convert.ToInt32(Console.ReadLine());
int result = 0;
for (int i = 0; i <= N; i++)
{
if (i % 2 != 0)
result += i;
}
Console.WriteLine(result);
}
}
z ‫ ﺇﻟﻰ‬a ‫ﺻﻣﻡ ﺑﺭﻧﺎﻣﺞ ﻟﻁﺑﺎﻋﺔ ﺍﻷﺣﺭﻑ ﻣﻥ‬ (26

static void Main(string[] args)


{
for (char x='a';x<='z';x++)
{
Console.Write(x+" ");
}
Console.WriteLine();

}
‫( ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺞ ﻳﻘﻭﻡ ﺑﺈﻳﺟﺎﺩ ﺃﻛﺑﺭ ﻗﻳﻣﺔ ﺑﻳﻥ ﻣﺟﻣﻭﻋﺔ ﺃﻋﺩﺍﺩ ﻳﺩﺧﻠﻬﺎ ﺍﻟﻣﺳﺗﺧﺩﻡ ) ﺍﻟﻣﺳﺗﺧﺩﻡ ﻳﺩﺧﻝ ﺻﻔﺭ‬27
(‫ﻋﻧﺩ ﺍﻻﻧﺗﻬﺎء‬

static void Main(string[] args)


{
int largest=0;
int x;
do
{
x = Convert.ToInt32(Console.ReadLine());
if (x > largest)
largest = x;
} while (x !=0);
Console.WriteLine(largest);
}
‫ﺍﻛﺗﺏ ﺑﺭﻧﺎﻣﺟﺎ ﻳﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺇﺩﺧﺎﻝ ﺭﻗﻡ ﻭﻳﻁﺑﻊ ﻟﻪ ﻫﻝ ﺍﻟﺭﻗﻡ ﺃﻭﻟﻲ ﺃﻡ ﻏﻳﺭ ﺃﻭﻟﻰ‬ (28

while (true)
{
Console.WriteLine("enter the number");
int num = Convert.ToInt32(Console.ReadLine());
string isNumP = "prime";
for (int i = 2; i < num; i++)
{
if (num % i == 0)
{
isNumP = "nonprime";
}
}

Console.WriteLine(isNumP);
}
: ‫ﺗﻣﺎﺭﻳﻥ‬ (29
static void Main(string[] args)
{
int i = 0;
int j = i++ + i;
Console.WriteLine(j); // i = 1,j = 1
}
static void Main(string[] args)
{
int i = 0;
int j = ++i + i;
Console.WriteLine(j); // i=1,j=2
}
static void Main(string[] args)
{
int d, a = 1, b = 2;
d = a++ + ++b;
Console.WriteLine("{0} {1} {2}", d, a, b); // d =4; a =2;b=3
}
static void Main(string[] args)
{
int a = 1, b = 1, d = 1;
Console.WriteLine("{0} {1} {2}", ++a + ++a + a++, a++ + ++b, ++d + d++ +
a++);            // 8 6 9 
            //a = 6, b = 2, d = 3
}
static void Main(string[] args)
{
int a = 5, b = 4;
int c = a++ * --b;
Console.Write("a={0}\tb={1}\tc={2}\n", a, b, c);
Console.WriteLine("a+b= " + a + b);
            // a =6 , b = 3 , c = 15 
            //a+b=63
}

‫ﺇﺩﺧﺎﻝ ﺭﻗﻡ ﻣﻭﺟﺏ ﻓﻘﻁ‬ (30


static void Main(string[] args)
{
int x;
do
{
Console.WriteLine("enter a positive number");
x = Convert.ToInt32(Console.ReadLine());
} while (x < 0);

}
‫( ﺭﻓﻊ ﻋﺩﺩ ﺇﻟﻰ ﻗﻭﺓ‬31
int x, y;
x = Convert.ToInt32(Console.ReadLine());
y = Convert.ToInt32(Console.ReadLine());
int output = 1;
for (int i = 1; i <= y; i++)
{
output = output * x;
}
Console.WriteLine(output);
.‫ﻋﺩﺩ ﻭ ﻁﺑﺎﻋﺔ ﻣﺟﻣﻭﻋﻬﻡ ﻭﺍﻟﻣﺗﻭﺳﻁ ﺍﻟﺣﺳﺎﺑﻲ ﻟﻬﻡ ﻭﺃﻛﺑﺭ ﻋﺩﺩ ﻭﺃﺻﻐﺭ ﻋﺩﺩ‬N ‫ﺇﺩﺧﺎﻝ‬ (32
Console.WriteLine("please enter the number N ");
int n = Convert.ToInt32(Console.ReadLine());
int x;
Console.Write("enter {0} number:", 1);
x = Convert.ToInt32(Console.ReadLine());
double sum = x;
int max=x;
int min=x;
for (int i=2;i<=n;i++)
{
Console.Write("enter {0} number:", i);
x = Convert.ToInt32(Console.ReadLine());
sum += x;
if (x > max)
max = x;
if (x < min)
min = x;
}

Console.WriteLine("the sumation of numbers is :{0}", sum);


Console.WriteLine("the average of numbers is :{0}", sum/n);
Console.WriteLine("the maximum of numbers is :{0}", max);
Console.WriteLine("the minimum of numbers is :{0}", min);
‫( ﺍﻛﺘﺐ ﺑﺮﻧﺎﻣﺠﺎ ﻳﻘﺮﺃ ﻣﺤﺮﻑ ﺛﻢ ﻳﻘﻮﻡ ﺑﻄﺒﺎﻋﺔ ﻫﻞ ﺍﻟﺤﺮﻑ ﺻﻮﺗﻲ‬33
.A,I,E,O,U ‫ﺍﻡ ﻻ ) ﺍﻷﺣﺮﻑ ﺍﻟﺼﻮﺗﻴﺔ ﻫﻲ‬
char letter = Convert.ToChar(Console.ReadLine());
if (letter == 'a' || letter == 'A' || letter == 'o' || letter == 'O' ||
letter == 'e' || letter == 'E' || letter == 'i' || letter == 'I' ||
letter == 'u' || letter == 'U')
Console.WriteLine("vowel");

You might also like