1 / 18

CivTeam.wordpress

محاضرات في البرمجة. المحاضرة الرابعة. القسم العملي. للمزيد زورونا على موقعنا الإلكتروني:. CivTeam.wordpress.com. الحلقات for. For i =1 To x step -2 …………. …………. Next. الحلقة Do while. DO while ( شرط ) …………. …………. Loop DO …………. ………….

terra
Télécharger la présentation

CivTeam.wordpress

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. محاضرات في البرمجة المحاضرة الرابعة القسم العملي للمزيد زورونا على موقعنا الإلكتروني: CivTeam.wordpress.com

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

  3. الحلقة Do while DO while (شرط) …………. …………. Loop DO …………. …………. Loop 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. الحلقة while 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

  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

More Related