Giter Site home page Giter Site logo

ios-cw-11's Introduction

شرح الدرس

  • استخدام for loop

اذا في كود قاعد اكرره عدد من المرات اقدر اختصره

طريقة كتابة بدون for loop

print("1 x 10 is \(1 * 10)")
print("2 x 10 is \(2 * 10)")
print("3 x 10 is \(3 * 10)")
print("4 x 10 is \(4 * 10)")
print("5 x 10 is \(5 * 10)")
print("6 x 10 is \(6 * 10)")
print("7 x 10 is \(7 * 10)")
print("8 x 10 is \(8 * 10)")
print("9 x 10 is \(9 * 10)")
print("10 x 10 is \(10 * 10)")

طريقة استخدام for loop

for i in 1...10 {
    print("\(i) x 10 is \(i * 10)")
}

التمرين

السؤال الاول :

  1. قم بتعريف المتغير التالي : مصفوفة من الأرقام العشوائية.
  2. استخدام for loop والمرور على الارقام وفي كل مرة نتاكد اذا كان العدد زوجي او فردي ونطبعها.

Hint:

لمعرفة العدد اذا كان العدد زوجي او فردي فيجب استخدام if وعمل "باقي القسمة على ٢ " واذا كان الناتج = صفر فهو زوجي ، اما اذا كان الناتج = واحد فهو فردي.

السؤال الثاني :

1. عرف متغير من نوع عدد صحيح -> var total = 0

2. عرف مصفوفة فيها عدد من الأرقام

3. اضف for loop تقوم في كل مره بجمع الرقم مع الناتج و طباعة الناتج النهائي

ios-cw-11's People

Contributors

bkmushaileh avatar bodouralrashidi avatar hasanals avatar omsi96 avatar ralenezi avatar shaimaa1236 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.