.נוריאל קסוקר
חוברת תרגילים לתרגול
יסודות התכנות
פעולות קלט ופלט
. הצג את שלושתם ואת תוצאת הסיכום, סכם אותם. מספרים3 קלוט
.1
static void Main(string[] args)
{
int num1, num2, num3,sum;
Console.WriteLine("please enter 3 numbers");
num1 = int.Parse(Console.ReadLine());
num2 = int.Parse(Console.ReadLine());
num3 = int.Parse(Console.ReadLine());
sum = num1 + num2 + num3;
Console.WriteLine("the first number is: {0}", num1);
Console.WriteLine("the secound number is: {0}", num2);
Console.WriteLine("the thierd number is: {0}", num3);
Console.WriteLine("the total sum is: {0}", sum);
}
. הצג את שלושתם ואת הממוצע החשבונאי שלהם. מספרים3 קלוט
.2
static void Main(string[] args)
{
int num1, num2, num3,average;
Console.WriteLine("please enter 3 numbers");
num1 = int.Parse(Console.ReadLine());
num2 = int.Parse(Console.ReadLine());
num3 = int.Parse(Console.ReadLine());
average = (num1 + num2 + num3)/3;
Console.WriteLine("the first number is: {0}", num1);
Console.WriteLine("the secound number is: {0}", num2);
Console.WriteLine("the thierd number is: {0}", num3);
Console.WriteLine("the total average is: {0}", average);
}
. מספרים והצג את מכפלתם3 קלוט
.3
static void Main(string[] args)
{
int num1, num2, num3, product;
Console.WriteLine("please enter 3 numbers");
num1 = int.Parse(Console.ReadLine());
num2 = int.Parse(Console.ReadLine());
num3 = int.Parse(Console.ReadLine());
product = num1 * num2 * num3;
Console.WriteLine("the first number is: {0}", num1);
Console.WriteLine("the secound number is: {0}", num2);
Console.WriteLine("the thierd number is: {0}", num3);
Console.WriteLine("the product is: {0}", product);
}
.) קלוט מספר והדפס את הריבוע שלו ( מכפלתו בעצמו
static void Main(string[] args)
{
int num1, square;
.4
.נוריאל קסוקר
Console.WriteLine("please enter number");
num1 = int.Parse(Console.ReadLine());
square = num1 * num1;
Console.WriteLine("the square of your number is: {0}",
square);
}
: מספרים וחשב לפי הסדר הבא4 קלוט
הוסף את הראשון לשלישי.5.1
החסר את השני מהרביעי.5.2
8- חלק את השלישי המקורי ב.5.3
) הכפל את הרביעי בראשון ( לפני ההוספה.5.4
הצג את התוצאות.5.5
לפתרון התרגיל ניתן להוסיף משתנה עזר: הערה-----
.5
static void Main(string[] args)
{
int num1,num2,num3,num4,sum1,dec1,dev1,multi;
Console.WriteLine("please enter 4 numbers");
num1 = int.Parse(Console.ReadLine());
num2 = int.Parse(Console.ReadLine());
num3 = int.Parse(Console.ReadLine());
num4 = int.Parse(Console.ReadLine());
sum1 = num1 + num3;
dec1 = num4 - num2;
dev1 = num3 / 8;
multi = num1 * num4;
Console.WriteLine("Answer1
Console.WriteLine("Answer2
Console.WriteLine("Answer3
Console.WriteLine("Answer4
is:
is:
is:
is:
{0}",
{0}",
{0}",
{0}",
sum1);
dec1);
dev1);
multi);
}
חזור על התרגיל הקודם ללא משתנה עזר בכלל
static void Main(string[] args)
{
double num1,num2,num3,num4;
Console.WriteLine("please enter 4 numbers");
num1 = int.Parse(Console.ReadLine());
num2 = int.Parse(Console.ReadLine());
num3 = int.Parse(Console.ReadLine());
num4 = int.Parse(Console.ReadLine());
num1 = num1 + num3;
num2 = num4 - num2;
num3 = num3 / 8;
num4 = (num1-(num3*8)) * num4;
Console.WriteLine("Answer1
Console.WriteLine("Answer2
Console.WriteLine("Answer3
Console.WriteLine("Answer4
is:
is:
is:
is:
{0}",
{0}",
{0}",
{0}",
num1);
num2);
num3);
num4);
.6
.נוריאל קסוקר
. הדפס את הממוצע שלהם עם הודעה מתאימה. מספרים שלמים2 כתוב תוכנית שתקלוט
.7
static void Main(string[] args)
{
double num1, num2,average;
Console.WriteLine("please enter 2 numbers");
num1 = int.Parse(Console.ReadLine());
num2 = int.Parse(Console.ReadLine());
average = (num1 + num2) / 2;
Console.WriteLine("The average of the two numbers is:
{0}", average);
}
.) לאחר מכן החלף את תוכנם ( השתמש במשתנה עזרB,A משתנים2 קלוט
.8
static void Main(string[] args)
{
double A,B,C ;
Console.WriteLine("please enter 2 numbers");
A = int.Parse(Console.ReadLine());
B = int.Parse(Console.ReadLine());
C = A;
A = B;
B = C;
Console.WriteLine("The two numbers are: {0},{1}",A,B );
}
חזור על התרגיל הקודם ללא משתנה עזר
.9
static void Main(string[] args)
{
double A,B;
Console.WriteLine("please enter 2 numbers");
A = int.Parse(Console.ReadLine());
B = int.Parse(Console.ReadLine());
A = A + B;
B = A - B;
A = A - B;
Console.WriteLine("The two numbers are: {0},{1}",A,B );
}
. הצג את שטח החדר ואת היקפו. קלוט אורך ורוחב של חדר מלבני.11
static void Main(string[] args)
{
double a,b,s,p;
Console.WriteLine("Please enter room length:");
a = int.Parse(Console.ReadLine());
Console.WriteLine("Please enter room wide:");
b = int.Parse(Console.ReadLine());
p = 2 * a + 2 * b;
s = a * b;
Console.WriteLine("The room perimeter is:{0}",p);
Console.WriteLine("The room size is:{0}",s);
}
קלוט אורך של סרט קולנוע בדקות והצג אורך הסרט בשעות ודקות.11
. 1 hour(s) and 28 minute(s) פלט, 88 – קלט: לדוגמא
.נוריאל קסוקר
static void Main(string[] args)
{
int a;
Console.WriteLine("Please enter film length in
minutes:");
a = int.Parse(Console.ReadLine());
int b = a / 60;
int s = (a % 60);
Console.WriteLine("Film time in hours {0} and {1}
minutes",b,s);
}
. מצא מהי ספרתו הימנית ביותר והדפס אותה. ספרות לפחות4 מובטח כי הוא בן, קלוט מספר.12
static void Main(string[] args)
{
int num;
Console.WriteLine("Please enter 4 digit number");
num = int.Parse(Console.ReadLine());
if ((num>=1000)&&(num<=9999))
{
int num1 = num % 10;
Console.WriteLine("The last digit of the number is:{0}",
num1);
}
else
{
Console.WriteLine("This is not 4 digit number");
}
}
. מצא מהי ספרתו השנייה מימין והדפס אותה. ספרות לפחות4 מובטח כי הוא בן, קלוט מספר.13
static void Main(string[] args)
{
int num,num3;
Console.WriteLine("Please enter 4 digit number");
num = int.Parse(Console.ReadLine());
if ((num>=1000)&&(num<=9999))
{
int num1 = num % 100;
int num2 = num % 10;
num3 = (num1 - num2) / 10;
Console.WriteLine("The secound digit of the number
is:{0}", num3);
}
else
{
Console.WriteLine("This is not 4 digit number");
}
}
. קלוט נתון תלת ספרתי והדפס את ספרת המאות.14
static void Main(string[] args)
{
int num,num3;
Console.WriteLine("Please enter 3 digit number");
num = int.Parse(Console.ReadLine());
.נוריאל קסוקר
if ((num>=100)&&(num<=999))
{
int num1 = num % 1000;
int num2 = num % 100;
num3 = (num1 - num2) / 100;
Console.WriteLine("The hundreds digit of the number
is:{0}", num3);
}
else
{
Console.WriteLine("This is not 3 digit number");
}
}
פרק אותו לספרותיו והדפס את הספרות עם הודעות.ספרתי- כתוב תוכנית שתקלוט מספר תלת.15
.מתאימות
static void Main(string[] args)
{
int num,num3;
Console.WriteLine("Please enter 3 digit number");
num = int.Parse(Console.ReadLine());
if ((num>=100)&&(num<=999))
{
int num1 = num % 10;
int num2 = (num % 100 -num1)/10;
num3 = (num -(num2*10) - num1)/100;
Console.WriteLine("The hundreds digit of the number
is:{0}", num3);
Console.WriteLine("The tens digit of the number is:{0}",
num2);
Console.WriteLine("The oneness digit of the number
is:{0}", num1);
}
else
{
Console.WriteLine("This is not 3 digit number");
}
}
. קלוט נתון דו ספרתי והדפס את סכום ספרותיו.16
static void Main(string[] args)
{
int num,num3;
Console.WriteLine("Please enter 2 digit number");
num = int.Parse(Console.ReadLine());
if ((num>=10)&&(num<=99))
{
int num1 = num % 10;
int num2 = ((num % 100)-num1)/10;
num3 = num1 + num2;
Console.WriteLine("The sum of the 2 digit of the number
is:{0}", num3);
}
else
{
Console.WriteLine("This is not 2 digit number");
}
}
.נוריאל קסוקר
. הפוך את סדר הספרות והצג את המספר החדש99 ל11 קלוט מספר שלם בין.17
16 - פלט, 61 – קלט: לדוגמא
static void Main(string[] args)
{
int num, num3;
Console.WriteLine("Please enter 2 digit number");
num = int.Parse(Console.ReadLine());
if ((num >= 10) && (num <= 99))
{
int num1 = num % 10;
int num2 = ((num % 100) - num1) / 10;
num3 = num1*10+num2;
Console.WriteLine("The new 2 digit number is:\n{0}",
num3);
}
else
{
Console.WriteLine("This is not 2 digit number");
}
}
משפטי תנאי
אם אחד מהם חיובי והשני שלילי על התוכנית. מספרים שלמים כלשהם2 כתוב תוכנית שתקלוט
.1
." אחרת התוכנית תדפיס "סימנים זהים,"להדפיס "סימנים מנוגדים
static void Main(string[] args)
{
int num1,num2;
Console.WriteLine("please enter 2 numbers:");
num1= int.Parse(Console.ReadLine());
num2= int.Parse(Console.ReadLine());
if ((num1>0 && num2<0) || (num1<0 && num2>0))
{
Console.WriteLine("The two numbers with different sign");
}
else
{
Console.WriteLine("The two numbers with the same sign");
}
}
.num1, num2 : מספרים שלמים2 כתוב תוכנית שתקלוט
גדולnum1 אך אם. התוכנית תחשב את הממוצע שלהם251- גדול מnum2- שלילי וnum1 אם
. התוכנית תחשב את מכפלתם,11- ל1 ביןnum2- ו311-מ
.בכל מקרה אחר התוכנית תדפיס את סכומם
static void Main(string[] args)
{
int num1, num2, average, product,sum;
Console.WriteLine("please enter 2 numbers:");
num1= int.Parse(Console.ReadLine());
num2= int.Parse(Console.ReadLine());
if (num1 < 0 && num2 > 250)
{
.2
.נוריאל קסוקר
average = (num1 + num2) / 2;
Console.WriteLine("The average of two numbers is:{0}", average);
}
if (num1 > 300 && 0 < num2 && num2 < 10)
{
product = num1 * num2;
Console.WriteLine("The product of the two numbers:{0}", product);
}
if((num1<=300 && num1>=0) || (num2<0))
{
sum = num1 + num2;
Console.WriteLine("The sum of the two numbers:{0}", sum);
}
}
. הדפס הודעה מתאימה.כתוב תוכנית שתקלוט מספר שלם ותבדוק האם הוא זוגי
.3
static void Main(string[] args)
{
int num;
Console.WriteLine("Please enter number:");
num = int.Parse(Console.ReadLine());
num = (num%2);
if(num!=0)
{
Console.WriteLine("This number not even");
}
else
{
Console.WriteLine("This number is even");
}
}
הדפס הודעה. התוכנית תבדוק האם סכום ספרותיו זוגי.ספרתי-כתוב תוכנית שתקלוט מספר דו
.מתאימה
static void Main(string[] args)
{
int num, num3,num4;
Console.WriteLine("Please enter 2 digit number");
num = int.Parse(Console.ReadLine());
if ((num >= 10) && (num <= 99))
{
int num1 = num % 10;
int num2 = ((num % 100) - num1) / 10;
num3 = (num1 + num2)%2;
num4 = num1 + num2;
if (num3!=0)
.4
.נוריאל קסוקר
Console.WriteLine("The sum of the 2 digit of the
number is not even:{0}",num4);
else
{
Console.WriteLine("The sum of the 2 digit number
is even:{0}",num4);
}
}
else
{
Console.WriteLine("This is not 2 digit number");
}
}
.ספרתי ותבדוק האם ספרת האחדות שווה לספרת העשרות-כתוב תוכנית שתקלוט מספר דו
.5
.הדפס הודעה מתאימה
static void Main(string[] args)
{
int num;
Console.WriteLine("Please enter 2 digit number");
num = int.Parse(Console.ReadLine());
if ((num >= 10) && (num <= 99))
{
int num1 = num % 10;
int num2 = ((num % 100) - num1) / 10;
if (num1!=num2)
Console.WriteLine("The 2 digit of the number are not
even!");
else
{
Console.WriteLine("The 2 digit number are
even!");
}
}
else
{
Console.WriteLine("This is not 2 digit number");
}
}
ספרתי ותבדוק האם סכום ספרת האחדות והמאות שווה-כתוב תוכנית שתקלוט מספר תלת
.)143 :לספרת העשרות (למשל
static void Main(string[] args)
{
int num, num3;
Console.WriteLine("Please enter 3 digit number");
num = int.Parse(Console.ReadLine());
if ((num >= 100) && (num <= 999))
{
int num1 = num % 10;
int num2 = (num % 100 - num1) / 10;
num3 = (num - (num2 * 10) - num1) / 100;
.6
.נוריאל קסוקר
Console.WriteLine("The hundreds digit of the number
is:{0}", num3);
Console.WriteLine("The tens digit of the number
is:{0}", num2);
Console.WriteLine("The oneness digit of the number
is:{0}", num1);
if (num2 != num1 + num3)
{
Console.WriteLine("This number is wrong");
}
else
{
Console.WriteLine("This number is ok");
}
}
else
{
Console.WriteLine("This is not 3 digit number");
}
.כתוב תוכנית שתקלוט שני מספרים ותדפיס את הגדול מביניהם
.7
static void Main(string[] args)
{
int num1, num2;
Console.WriteLine("Please enter 2 numbers:");
num1 = int.Parse(Console.ReadLine());
num2 = int.Parse(Console.ReadLine());
if (num1>num2)
{
Console.WriteLine("The bigger number is:\n{0}",num1);
}
else
{
Console.WriteLine("The bigger number is:\n{0}",num2);
}
}
.כתוב תוכנית שתקלוט שלושה מספרים שלמים ותדפיס את הגדול מביניהם
static void Main(string[] args)
{
{
int num1, num2, num3;
Console.WriteLine("Please enter 3 numbers:");
num1 = int.Parse(Console.ReadLine());
num2 = int.Parse(Console.ReadLine());
num3 = int.Parse(Console.ReadLine());
{
if (num1 > num2)
{
if (num2 > num3)
{
.8
.נוריאל קסוקר
Console.WriteLine("The biggest number is:\n{0}", num1);
}
}
if (num2 > num1)
{
if (num2 > num3)
Console.WriteLine("The biggest number is:\n{0}", num2);
}
if (num3 > num1)
{
if (num3 > num2)
Console.WriteLine("The biggest number is:\n{0}", num3);
}
}}}}}
התוכנית תבדוק האם הם ממוינים בסדר עולה. מספרים שלמים3 כתוב תוכנית שתקלוט
.9
.)2,6,9:(למשל
static void Main(string[] args)
{
{
int num1, num2, num3;
Console.WriteLine("Please enter 3 numbers:");
num1 = int.Parse(Console.ReadLine());
num2 = int.Parse(Console.ReadLine());
num3 = int.Parse(Console.ReadLine());
{
if (num3 > num2)
{
if (num2 > num1)
{
Console.WriteLine("The numbers order are ok");
}
else
{
Console.WriteLine("the Numbers order is not ok");
}
}
else
{
Console.WriteLine("the Numbers order is not ok");
}
}
}
}
}}
התוכנית תסדר את המספרים בסדר עולה ותדפיס. מספרים שלמים3 כתוב תוכנית שתקלוט.11
: על מנת למיין את המספרים השתמש באלגוריתם הבא.אותם
.b- לa החלף ביןa>b אם
.c- לa החלף ביןa>c אם
.c- לb החלף ביןb>c אם
static void Main(string[] args)
{
{
int num1, num2, num3,temp;
Console.WriteLine("Please enter 3 numbers:");
num1 = int.Parse(Console.ReadLine());
num2 = int.Parse(Console.ReadLine());
num3 = int.Parse(Console.ReadLine());
.נוריאל קסוקר
{
if (num3 > num2 && num3>num1)
{
num3 = num3;
if (num2
{
num2
}
else
{
temp
num2
num1
}
> num1)
= num2;
= num2;
= num1;
= temp;
}
if (num2 > num1 && num2 > num3)
{
if (num3
{
temp
num2
num3
}
else
{
temp
num1
num3
temp
num2
num3
> num1)
= num2;
= num3;
= temp;
=
=
=
=
=
=
num1;
num3;
temp;
num2;
num3;
temp;
}
}
if (num1 > num2 && num1 > num3)
{
num1 = num1;
if (num3
{
num3
}
else
{
temp
num1
num3
}
> num1)
= num3;
= num1;
= num3;
= temp;
}
ללאA מתחלק בB ובודקת האםB , A מספרים שלמים למשתנים2 כתוב תוכנית שקולטת.13
. " not divide " " אחרת הדפסdivide" אם כן הדפס,שארית
.נוריאל קסוקר
static void Main(string[] args)
{
{
int A, B,num;
Console.WriteLine("Please enter 2 numbers:");
A = int.Parse(Console.ReadLine());
B = int.Parse(Console.ReadLine());
num = B / A % 10;
if (num != 0)
{
Console.WriteLine("divide:\n{0}", num);
}
else
{
Console.WriteLine("not divide");
}
}
}
}
}
עליך לבדוק האם המשולש הוא שווה צלעות והדפס, צלעות של משולש3 כתוב תוכנית שקולטת.14
. הודעה מתאימה
static void Main(string[] args)
{
{
int AB,BC,AC;
Console.WriteLine("Please enter 3 numbers for the equilateral
triangle");
AB = int.Parse(Console.ReadLine());
BC = int.Parse(Console.ReadLine());
AC = int.Parse(Console.ReadLine());
if (AB == BC)
{
if (AB == AC)
{
Console.WriteLine("You got equilateral triangle:\n");
}
else
{
Console.WriteLine("This is not equilateral triangle");
}
}
else
{
Console.WriteLine("This is not equilateral triangle");
}
}
}
}
}
עליך לבדוק האם המשולש הוא שווה שוקיים, צלעות של משולש3 כתוב תוכנית שקולטת.15
. והדפס הודעה מתאימה
.נוריאל קסוקר
static void Main(string[] args)
{
{
int AB,BC,AC;
Console.WriteLine("Please enter 3 numbers for the isosceles
triangle");
AB = int.Parse(Console.ReadLine());
BC = int.Parse(Console.ReadLine());
AC = int.Parse(Console.ReadLine());
if ((AB == BC)||(BC==AC)||(AC==AB))
{
Console.WriteLine("You got isosceles triangle\n");
}
else
{
Console.WriteLine("This is not isosceles triangle");
}
}
}
}
}
וגובה מעל51-81 או בין21-41 גיל בין: תנאי הקבלה הם, חברת היי טק מחפשת עובדים.16
תבדוק את פרטי המועמד ותדפיס הודעה האם, כתוב תוכנית שקולטת פרטי מועמד, ס"מ181-ל
.התקבל או לא
static void Main(string[] args)
{
{
float Age, Height;
Console.WriteLine("Please enter age of the
candidate");
Age = float.Parse(Console.ReadLine());
Console.WriteLine("Please enter height of the
candidate");
Height = float.Parse(Console.ReadLine());
if (((Age >= 20) && (Age <= 40)) || ((Age >= 50) &&
(Age <= 80)))
{
if (Height > 1.80)
{
Console.WriteLine("You got your
candidate\n");
}
}
else
{
Console.WriteLine("This is not what you looking
for check for another candidate");
}
}
}
}
}
.נוריאל קסוקר
בתנאי שלאחר העלאה,11% – בעל בית תוכנה החליט להעלות את המשכורת של כל תכניתן ב.17
יקבל אותו תוכניתן העלאה,₪ 6,111 - אם הסכום אכן יהיה גבוה מ. 6,111 -כזו לא יהיה גבוה מ
. בלבד5% של
קלוט את שמו של התוכניתן ואת משכורתו הנוכחית והצג את המשכורת של התוכניתן לאחר
.ההעלאה
static void Main(string[] args)
{
{
double Salary;
string Name;
Console.WriteLine("Please enter Name of the employe:");
Name = (Console.ReadLine());
Console.WriteLine("Please enter employe's salary:");
Salary = Double.Parse(Console.ReadLine());
if ((Salary*1.1)>6000)
{
Salary = Salary * 1.05;
{
Console.WriteLine("this is {0}'s new salary: {1}\n",Name,Salary);
}
}
else
{
Salary=Salary*1.1;
Console.WriteLine("this is {0}'s new salary: {1}\n", Name, Salary);
}
}
}
}
}
(. אם המספר חורג מהתחום הצג הודעת שגיאה, והצג את שמו במילים11 לבין1 קלוט מספר בין.18
. )switch ניתן להשתמש במשפט
static void Main(string[] args)
{
int num;
Console.WriteLine("Enter Number for 1 to 10;\n");
num = int.Parse(Console.ReadLine());
switch (num)
{
case 1:
Console.WriteLine("You choose - One\n");
break;
case 2:
Console.WriteLine("You choose - Two\n");
break;
case 3:
Console.WriteLine("You choose - three\n");
break;
case 4:
Console.WriteLine("You choose - four\n");
break;
case 5:
Console.WriteLine("You choose - Five\n");
break;
case 6:
Console.WriteLine("You choose - Six\n");
break;
.נוריאל קסוקר
case 7:
Console.WriteLine("You choose - Seven\n");
break;
case 8:
Console.WriteLine("You choose - Eight\n");
break;
case 9:
Console.WriteLine("You choose - Nine\n");
break;
Console.WriteLine("You choose - Ten\n");
break;
default:
Console.WriteLine("Invalid number Please select number form 1 to
10.");
break;
}
}
}
}
. הצג את מספר ספרותיו.9,999 ל1 קלוט מספר שלם בין.19
static void Main(string[] args)
{
int num;
Console.WriteLine("Enter Number for 1 to 9999:\n");
num = int.Parse(Console.ReadLine());
if (num<10)
{Console.WriteLine("You choose - One digit number\n");}
if ((num>=10)&&(num<100))
{
Console.WriteLine("You choose - Two digit number\n");}
if((num>=100)&&(num<1000))
{Console.WriteLine("You choose - three digit number\n");}
if ((num>=1000)&&(num<10000))
{Console.WriteLine("You choose - four digit number\n");}
}
}
}
מנהל בית ספר "יסוד" החליט שלא יופיעו בתעודות הציונים המספריים אלא הערכה מילולית לפי.21
: המפתח הבא
בלתי מספיק 55 פחות מ
64 עד55
כמעט טוב 74 עד65
. טוב 84 עד75
טוב מאוד 94 עד85
מצוין ומעלה95
מספיק
. קלוט ציון של תלמיד והצג את ההערכה המילולית המתאימה
static void Main(string[] args)
{
int num;
Console.WriteLine("Enter Student grade:\n");
num = int.Parse(Console.ReadLine());
if (num<55)
{Console.WriteLine("Unsatisfactory\n");}
if ((num>=55)&&(num<65))
{
Console.WriteLine("Enough\n");}
if((num>=65)&&(num<75))
.נוריאל קסוקר
{Console.WriteLine("Allmost Good\n");}
if ((num>=75)&&(num<85))
{Console.WriteLine("Good\n");}
if ((num >= 85) && (num < 95))
{ Console.WriteLine("Very Good\n"); }
if ((num >= 95) && (num <= 100))
{ Console.WriteLine("Excellent\n"); }
}
}
}
: הם נעלמיםy - וx – ו, הם מקדמיםa,b,c,d,e,f במערכת המשוואות הבאה.21
ax+by=c
dx+ey=f
: ע"י נוסחאות העזר הבאותy ואתx ניתן לחשב את
c*e b* f
a*e b*d
a* f c*d
y
a*e b*d
x
ולהציג,1 יש לשים לב בחלוקה עם, והצג את הפתרוןa,b,c,d,e,f, קלוט את המקדמים
. הודעה מתאימה
static void Main(string[] args)
{
float a,b,c,d,e,f,x,y;
Console.WriteLine("Enter all numbers that needed:\n");
a = float.Parse(Console.ReadLine());
b = float.Parse(Console.ReadLine());
c = float.Parse(Console.ReadLine());
d = float.Parse(Console.ReadLine());
e = float.Parse(Console.ReadLine());
f = float.Parse(Console.ReadLine());
if (a*e-b*d!=0)
{
x=((c*e-b*f) / (a*e-b*d));
y=((a*f-c*d) / (a*e-b*d));
Console.WriteLine("x={0}\n", x);
Console.WriteLine("Y={0}\n", y);
}
else
{Console.WriteLine("Illegal try again\n");}
}
}
}
כתוב תוכנית שקולטת את שלושת המקדמים של המשוואה הריבועית ומחשבת את תוצאות.22
: המשווה לפי התנאים הבאים
אין משוואה ריבועית- a=0
אין פתרון- 0
b
- פתרון יחיד- 0
2a
x1, 2
b b 2 4ac
- פתרונות2 - 0
2a
.נוריאל קסוקר
static void Main(string[] args)
{
double delta, a, b, c, x1, x2,delta1;
Console.WriteLine("Enter all numbers that needed:\n");
a = double.Parse(Console.ReadLine());
b = double.Parse(Console.ReadLine());
c = double.Parse(Console.ReadLine());
delta= ((b*b)-(4*a*c));
if (delta<0)
{
Console.WriteLine("No answer");
}
if (delta==0)
{
x1 = (-b / (2 * a));
Console.WriteLine("X1={0}\n",x1);
}
if (delta > 0)
{
delta1 = Math.Sqrt(delta);
x1 = (-b - delta1)/ (2 * a);
x2 = (-b + delta1) / (2 * a);
Console.WriteLine("X1={0}\n", x1);
Console.WriteLine("X2={0}\n", x2);
}
}
}
}
: מספרים ומציגה על המסך את תפריט האפשריות הבא2 כתוב תוכנית שקולטת.23
1.add
2.sub
3.div
4.mul
5.power
המשתמש צריך לבחור במספר האופציה ולפיה להציג את תוצאת החישוב ( יש להשתמש במשפט
. )switch
static void Main(string[] args)
{
double a, b;
int num;
Console.WriteLine("Enter 2 numbers:\n");
a = double.Parse(Console.ReadLine());
b = double.Parse(Console.ReadLine());
Console.WriteLine("1.add\n2.sub\n3.div\n4.mul\n5.power\n");
Console.WriteLine("Enter your choice");
num = int.Parse(Console.ReadLine());
switch (num)
{
case 1:
a = a + b;
Console.WriteLine("ADD : {0}\n", a);
break;
case 2:
a = a - b;
.נוריאל קסוקר
Console.WriteLine("SUB :
break;
case 3:
a = a / b;
Console.WriteLine("DIV :
break;
case 4:
a = a * b;
Console.WriteLine("MUL :
break;
case 5:
a = Math.Pow (a, b);
Console.WriteLine("POWER
break;
{0}\n", a);
{0}\n", a);
{0}\n", a);
: {0}\n", a);
}
}
}
}
לולאות
. עבור כל מספר הדפס את סכום ספרותיו.ספרתיים- מספרים תלת11 כתוב תוכנית שקולטת
.1
static void Main(string[] args)
{
int i = 0, num;
while (i < 10)
{
Console.WriteLine("Please enter 3 digit number");
num = int.Parse(Console.ReadLine());
if ((num >= 100) && (num <= 999))
{
int num1 = num % 10;
int num2 = ((num % 100) - num1) / 10;
int num3 = ((num % 1000) - (num % 100)) / 100;
int sum = num1 + num2 + num3;
Console.WriteLine("The sum of this 3 digit number is:{0}", sum);
i++;
}
else
{
Console.WriteLine("This is not 3 digit number");
}}}}}
מצא את כל. סכום ספרותיו בשלישית שווה למספר בעצמו: מקיים את התנאי371 המספר
.ספרתיים שמקיימים תנאי זה-המספרים התלת
static void Main(string[] args)
{
.2
.נוריאל קסוקר
int num = 100,num4;
while (num < 1000)
{
int num1 = num % 10;
int num2 = ((num % 100) - num1) / 10;
int num3 = ((num % 1000) - (num % 100)) / 100;
int sum = num1 + num2 + num3;
num4 = sum * sum * sum;
if (num == num4)
{
Console.WriteLine("The number is ok:{0}", num);
}
num++;
}
}
}
}
סכום חציו הימני עם חציו השמאלי בריבוע שווה למספר: מקיים את התנאי הבא3125 המספר
.3
.ספרות שמקיימים תנאי זה- מצא את כל המספרים בעלי ארבע.עצמו
static void Main(string[] args)
{
int num4,num=1000;
while (num<10000)
{
int num1 = num % 100;
int num2 = ((num % 10000) - (num % 100))/100;
int sum = num1 + num2;
num4 = sum * sum;
if (num4==num)
{
Console.WriteLine("The number is ok:{0}", num);
}
num++;
}
}
}
.כתוב תוכנית שקולטת שני מספרים ומכפילה אותם מבלי להשתמש בפעולת כפל
.4
static void Main(string[] args)
{
int num1, num2;
Console.WriteLine("please enter two numbers\n");
num1 = int.Parse(Console.ReadLine());
num2 = int.Parse(Console.ReadLine());
long num3 = Math.BigMul(num1, num2);
Console.WriteLine("answer is {0}\n", num3);
}
}
}
3-ספרתיים שבהם ספרת העשרות קטנה ב-כתוב תוכנית שתציג כפלט את כמות המספרים התלת
. מספרת העשרות2-מספרת האחדות וספרת המאות גדולה ב
.5
.נוריאל קסוקר
static void Main(string[] args)
{
int num=100,total=0;
while (num < 1000)
{
int num1 = num % 10;
int num2 = ((num % 100) - num1) / 10;
int num3 = ((num % 1000) - (num % 100)) / 100;
if ((num3 == (num2 + 2)) && (num1 == (num2 - 3)))
{
Console.WriteLine("The number is:{0}", num);
total++;
}
num++;
if (num == 1000)
{
Console.WriteLine("the total numbers is:{0}\n", total);
}
}
}
}
}
.5 ספרתיים שמכילים את הספרה-כתוב תוכנית שתציג את כל המספרים הדו
.6
static void Main(string[] args)
{
int num=10,total=0;
while (num < 100)
{
int num1 = num % 10;
int num2 = ((num % 100) - num1) / 10;
if ((num1 == 5) || (num2 == 5))
{
Console.WriteLine("The number is:{0}", num);
total++;
}
num++;
if (num == 100)
{
Console.WriteLine("the total numbers is:{0}\n", total);
}
}
}
}
}
.זוגיות שבו- הצג כפלט את כמות הספרות האי.כתוב תוכנית שתקלוט מספר שאורכו אינו ידוע
static void Main(string[] args)
{
.7
.נוריאל קסוקר
double num, num1,num2;
int i = 0;
Console.WriteLine("Please enter number:");
num = double.Parse(Console.ReadLine());
while (num != 0)
{
num1 = num % 10;
num2 = num1 % 2;
num = (num - num1) / 10;
if (num2 != 0)
{
i++;
}
}
Console.WriteLine("you have {0} non even digit in your number\n", i);
}
}
}
עם,55- וכמה קטנים מ91- הצג כפלט כמה מהציונים גדולים מ. ציונים11 כתוב תוכנית שתקלוט
.8
.הודעות מתאימות
static void Main(string[] args)
{
double num;
int i = 0,a=0,b=0;
while (i < 10)
{
Console.WriteLine("Please enter number:");
num = double.Parse(Console.ReadLine());
if ((num > 90) && (num <= 100))
{
a++;
}
if (num<55)
{
b++;
}
i++;
}
Console.WriteLine("you have {0} grades above 90.\n", a);
Console.WriteLine("you have {0} grades under 55.\n", b);
}
}
}
הצג כפלט.ספרתי-ספרתיים עד שבקלט יופיע מספר שאינו דו-כתוב תוכנית שתקלוט מספרים דו
. מספרת העשרות2-את כמות המספרים שבהם ספרת האחדות גדולה ב
static void Main(string[] args)
{
.9
.נוריאל קסוקר
double num,num1,num2;
int i=0;
Console.WriteLine("Please enter 2 digit number:");
num = double.Parse(Console.ReadLine());
while ((9 < num) && (num < 100))
{
num1=num%10;
num2=(num-num1)/10;
if ((num1-num2)==2)
{
i++;
}
Console.WriteLine("Please enter 2 digit number:");
num = double.Parse(Console.ReadLine());
}
Console.WriteLine("the total is : {0}\n",i);
}
}
}
זוגיות" הוא מספר שאורכו לא ידוע ובו סכום הספרות הזוגיות שווה לסכום- מספר "שווה.11
בדוק והדפס הודעה, כתוב תוכנית שתקלוט מספר שלם שאורכו אינו ידוע.זוגיות-הספרות האי
.זוגיות" או לא- האם המספר "שווה,מתאימה
. הם מספרים מאוזנים9281 ,112 , 2671 : דוגמאות
static void Main(string[] args)
{
double num, num1, num2;
int i = 0,a=0;
Console.WriteLine("Please enter number:");
num = double.Parse(Console.ReadLine());
while (num != 0)
{num1 = num % 10;
num2 = num1 % 2;
num = (num - num1) / 10;
if (num2 != 0)
{i++;}
else
{a++;}}
Console.WriteLine("you have {0} non even digit in your number\n", i);
Console.WriteLine("you have {0} even digit in your number\n", a);
if (a == i)
{
Console.WriteLine("this is good Number\n");
}
else
{
Console.WriteLine("this is not good Number\n");
}}}}
ספרתי כסכום של מכפלת שתי הספרות הראשונות של המספר- נגדיר "משקל" של מספר תלת.11
.ושל מכפלת שתי הספרות האחרונות שלו
.3*222*7=21 : הוא327 ה"משקל" של המספר:לדוגמה
התוכנית תחשב ותדפיס עבור כל מספר.ספרתיים- מספרים תלת11 כתוב תוכנית שתקלוט
.את ה"משקל" שלו
.נוריאל קסוקר
static void Main(string[] args)
{
double num, num1, num2,num3,sum;
int n=0;
while (n< 10)
{
Console.WriteLine("Please enter number:");
num = double.Parse(Console.ReadLine());
if ((num > 99) && (num < 1000))
{
num1 = num % 10;
num2 = ((num % 100) - num1) / 10;
num3 = ((num - num1 - (num2 * 10)) / 100);
sum = (num1 * num2 + num2 * num3);
Console.WriteLine("this is the sum of your number:\n{0}", sum);
n++;
}
else
{
Console.WriteLine("please enter 3 digit number\n");
}}}}}
כתוב תוכנית. לא כולל את עצמו, מספר "מאוזן" הוא מספר ששווה לסכום מחלקיו.12
6=1+2+3 הוא מאוזן כי6 (המספר.שתקלוט מספר ותציג כפלט הודעה האם הוא מאוזן או לא
). הוא מספר מאוזן28 גם,
static void Main(string[] args)
{
int num, num1;
int n=1,sum=0;
Console.WriteLine("Please enter number:");
num = int.Parse(Console.ReadLine());
while (n < num)
{
num1=num%n;
if (num1 == 0)
{
sum = sum + n;
n++;
}
else
{
n++;
}}
if (num == sum)
{
Console.WriteLine("this is good Number\n{0}", sum);
}
else
{
Console.WriteLine("this is not what you looking for");
}}}}
.נוריאל קסוקר
כתוב תוכנית שתציג את כל המספרים התלת ספרתיים שבהם ספרת האחדות שווה לספרת.13
סכום ספרת האחדות והמאות, ספרת המאות שווה לסכום ספרת האחדות והעשרות,העשרות
) (כל אחד כתרגיל נפרד5-שווה ל
static void Main(string[] args)
{double num1, num2, num3, sum;
int num = 100;
while (num < 1000)
{{num1 = num % 10;
num2 = ((num % 100) - num1) / 10;
num3 = ((num - num1 - (num2 * 10)) / 100);
if (num1 == num2)
{Console.WriteLine("this is one of your numbers:\n{0}", num);
num++;}
else{num++;}}}}}}
static void Main(string[] args)
{double num1, num2, num3;
int num = 100;
while (num < 1000)
{{num1 = num % 10;
num2 = ((num % 100) - num1) / 10;
num3 = ((num - num1 - (num2 * 10)) / 100);
if (num3== num2+num1)
{Console.WriteLine("this is one of your numbers:\n{0}", num);
num++;}
else{num++;}}}}}}
© Copyright 2025