Presentation is loading. Please wait.

Presentation is loading. Please wait.

مسألة أكتب برنامجاً يقوم بقراءة عددين و إظهار رسالة تفيد بأن أحد العددين هو المضاعف النوني للعدد الآخر و في حال عدم كون أي من العددين مضاعفاً للآخر يظهر.

Similar presentations


Presentation on theme: "مسألة أكتب برنامجاً يقوم بقراءة عددين و إظهار رسالة تفيد بأن أحد العددين هو المضاعف النوني للعدد الآخر و في حال عدم كون أي من العددين مضاعفاً للآخر يظهر."— Presentation transcript:

1

2 مسألة أكتب برنامجاً يقوم بقراءة عددين و إظهار رسالة تفيد بأن أحد العددين هو المضاعف النوني للعدد الآخر و في حال عدم كون أي من العددين مضاعفاً للآخر يظهر البرنامج رسالة تفيد بعدم وجود التضاعف أداة الشرط

3 Sub Main() Dim x, y As Single, n As Int16 Console.WriteLine("Enter the first number x") x = Console.ReadLine() Console.WriteLine("Enter the second number y") y = Console.ReadLine() If x = y Then Console.WriteLine("x and y are congruant") Console.ReadLine() Exit Sub End If If y Mod x = 0 Then n = y / x Console.WriteLine("y is the " & n & " multiple of x") ElseIf x Mod y = 0 Then n = x / y Console.WriteLine("x is the " & n & " multiple of y") Else Console.WriteLine("Neither x nor y is a multiple of the other") End If Console.ReadLine() End Sub أداة الشرط

4 مسألة (1) أكتب برنامجاً يقوم بقراءة عدد محصور بين الواحد و التسعة و إظهار كلمة odd للأعداد الفردية و كلمة even للأعداد الزوجية و عبارة out of range للأعداد التي لا تنتمي إلى المجال المذكور أداة الاختيار Select Case a Case 0 ……. Case 1 …….. Case Else …………. End Select

5 Sub Main() Dim a As Int16 Console.WriteLine("Enter a number between 1 and 9") a = Console.ReadLine Select Case a Case 1, 3, 5, 7, 9 Console.WriteLine("Odd number") Case 2, 4, 6, 8 Console.WriteLine("Even number") Case Else Console.WriteLine("Out of range") End Select Console.ReadLine() End Sub أداة الاختيار

6 مسألة (2) أكتب برنامجاً يقوم بقراءة عدد ما و إظهار كلمة odd للأعداد الفردية و كلمة even للأعداد الزوجية و عبارة Not an integer للأعداد غير الصحيحة أداة الاختيار

7 Sub Main() Dim a As Single Console.WriteLine("Enter any integer number") a = Console.ReadLine Select Case a Mod 2 Case 0 Console.WriteLine("Even number") Case 1 Console.WriteLine("Odd number") Case Else Console.WriteLine("Not an integer") End Select Console.ReadLine() End Sub أداة الاختيار

8 مسألة أكتب برنامجاً يقوم بقراءة عدد صحيح و إخراج جميع قواسمه على الشاشة الحلقة for For i =1 To x step -2 …………. Next

9 Sub Main() stu: Dim st As String Dim x As Single Console.WriteLine("Enter a number") x = Console.ReadLine If x Mod 1 <> 0 Then Console.WriteLine("Not an integer") Console.ReadLine() Exit Sub End If الحلقة for

10 Console.WriteLine("The divisors of " & x & " are:") For i As Int16 = 1 To x If x Mod i = 0 Then Console.WriteLine(i) End If Next Console.WriteLine("press r to repeat or x to exit") st = Console.ReadLine If st = "r" Then GoTo stu ElseIf st = "x" Then Exit Sub End If End Sub الحلقة for

11 While شرط ما ….. تزايد للعداد End While مسألة أكتب برنامجاً يقوم بحساب العاملي لعدد معطى الحلقة while

12 Sub Main() Dim cnt As Int16 = 1 Dim x As Int32 Dim xf As Int32 = 1 Console.WriteLine("Enter x") x = Console.ReadLine While cnt < x cnt = cnt +1 xf = xf * cnt End While Console.WriteLine(xf) Console.ReadLine() End Sub الحلقة while

13 Imports System.Console Imports System.math Module Module1 Sub Main() Dim tt As Integer WriteLine("integer(Rang)={0} to {1}", tt.MaxValue, tt.MinValue) 'WriteLine("integer(min)={0}", tt.MinValue) WriteLine(Sqrt(9)) ReadLine() End Sub End Module

14 مسائل في البرمجة مسألة أكتب برنامجاً يقوم بحساب المساحة و المحيط للأشكال الهندسية ( المستطيل، المربع، المثلث، الدائرة)

15 مسائل في البرمجة Imports System.Math Imports System. Console Module Module1 Sub Main() Dim wrng As Boolean Dim shp As String Dim a, c As Single str: WriteLine("Press 'r' for rectangle") WriteLine("or 's' for square") WriteLine("or 't' for triangle") WriteLine("or 'c' for circle") shp = ReadLine wrng = False

16 مسائل في البرمجة Select Case shp Case "r" Dim l, w As Single WriteLine("Enter the length") l = ReadLine WriteLine("Enter the width") w = ReadLine a = l * w c = 2 * (l + w)

17 مسائل في البرمجة Case "s" Dim s As Single WriteLine("Enter the side") s = ReadLine a = s ^ 2 c = 4 * s

18 مسائل في البرمجة Case "t" Dim s1, s2, s3, b, h As Single WriteLine("Enter the first side") s1 = ReadLine WriteLine("Enter the second side") s2 = ReadLine WriteLine("Enter the third side") s3 = ReadLine WriteLine("Enter the base") b = ReadLine WriteLine("Enter the height") h = ReadLine a = (b * h) / 2 c = s1 + s2 + s3

19 مسائل في البرمجة Case "c" Dim r As Single WriteLine("Enter the radius") r = ReadLine a = pi * r ^ 2 c = 2 * PI * r Case Else wrng = True WriteLine("Wrong selection") GoTo str End Select If Not wrng Then WriteLine("Area= " & a) WriteLine("Circumference= " & c) End If

20 مسائل في البرمجة WriteLine("Press 'r' to return or 'x' to exit") Dim st As String st = ReadLine If st = "r" Then GoTo str ElseIf st = "x" Then Exit Sub End If End Sub End Module


Download ppt "مسألة أكتب برنامجاً يقوم بقراءة عددين و إظهار رسالة تفيد بأن أحد العددين هو المضاعف النوني للعدد الآخر و في حال عدم كون أي من العددين مضاعفاً للآخر يظهر."

Similar presentations


Ads by Google