Presentation is loading. Please wait.

Presentation is loading. Please wait.

الحلقات for For i =1 To x step -2 …………. Next DO while (شرط) …………. Loop DO …………. Loop while (شرط) الحلقة Do while.

Similar presentations


Presentation on theme: "الحلقات for For i =1 To x step -2 …………. Next DO while (شرط) …………. Loop DO …………. Loop while (شرط) الحلقة Do while."— Presentation transcript:

1

2 الحلقات for For i =1 To x step -2 …………. Next

3 DO while (شرط) …………. Loop DO …………. Loop while (شرط) الحلقة Do while

4 Imports System.Console Module Sum1 Sub Main() Dim Sum, num As Double Sum = 0 WriteLine("Enter a positive number ") num = ReadLine() Do While (num > 0) Sum = Sum + num WriteLine("Enter another positive number ") num = ReadLine() Loop WriteLine("Sum= " & Sum) End Sub End Module

5 Imports System.Console Module Sum2 Sub Main() Dim Sum, num As Double Sum = 0 Do WriteLine("Enter a positive number ") num = ReadLine() If (num > 0) Then Sum = Sum + num End If Loop While (num > 0) WriteLine("Sum= " & Sum) End Sub End Module

6 Imports System.Console Module insist Sub Main() Dim x As Integer Do WriteLine("Enter a value larger than 0") x = ReadLine() Loop While (x <= 0) End Sub End Module

7 PI PI/4 = 1/1 - 1/3 + 1/5 - 1/7 +... PI = 4/1 - 4/3 + 4/5 - 4/7 +...

8 Imports System.Console Imports System.Math Module MyPI Sub Main() Dim p, part, res As Double Dim i, n As Integer Write("How many digits after decimal point: ") n = ReadLine() res = 1.0 / (10 ^ (n + 1)) i = 1 p = 0 part = 4 Do While (Abs(part) > res) p = p + part i = i + 2

9 If (part > 0) Then part = -4 / i Else part = 4 / i End If Loop WriteLine("My PI= " & p) WriteLine("VB PI= " & PI) End Sub End Module

10 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

11 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

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

13 مسائل في البرمجة 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

14 مسائل في البرمجة 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)

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

16 مسائل في البرمجة 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

17 مسائل في البرمجة 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

18 مسائل في البرمجة 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 "الحلقات for For i =1 To x step -2 …………. Next DO while (شرط) …………. Loop DO …………. Loop while (شرط) الحلقة Do while."

Similar presentations


Ads by Google