0% found this document useful (0 votes)
25 views

واجب برمجه

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

واجب برمجه

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

‫لغه برمجه‬

‫ سلطان الرشيدات‬:‫اعداد الطالب‬


‫ معاذ شطناوي‬.‫د‬:‫مدرس المساق‬

-NASTED IF-1
>include <iostream#

;Using namespace std

)(Int main

;Int mark1, mark2, mark3, mark4, mark5

;Int sum = 0

;Double avg
;Cin >> mark1 >> mark2 >> mark3 >> mark4 >> mark5

;Sum = mark1 + mark2 + mark3 + mark4 + mark5

;Avg = static_cast<double>(sum) / 5.0

;Cout << “The average is = “ << avg << endl

If (avg >= 90 && avg <= 100)

;Cout << “A With rate: “ << avg << endl

If (avg >= 80 && avg < 90)

;Cout << “B With rate: “ << avg << endl

If (avg >= 70 && avg < 80)

;Cout << “C With rate: “ << avg << endl

If (avg >= 60 && avg < 70)

;Cout << “D With rate: “ << avg << endl

If (avg >= 50 && avg < 60)

;Cout << “E With rate: “ << avg << endl

Else

2
{

;"Cout << “The student failed

;Return 0

-SWITCH- 2

>include <iostream#

;Using namespace std

)(Int main

;Int mark1, mark2, mark3, mark4, mark5

;Int sum = 0

;Double avg

;Cin >> mark1 >> mark2 >> mark3 >> mark4 >> mark5

;Sum = mark1 + mark2 + mark3 + mark4 + mark5

3
;Avg = static_cast<double>(sum) / 5.0

;Cout << “The average is = “ << avg << endl

Switch (static_cast<int>(avg) / 10)

:Case 10

:Case 9

;Cout << “A With rate: “ << avg << endl

;Break

:Case 8

;Cout << “B With rate: “ << avg << endl

;Break

:Case 7

;Cout << “C With rate: “ << avg << endl

;Break

:Case 6

;Cout << “D With rate: “ << avg << endl

;Break

:Case 5

;Cout << “E With rate: “ << avg << endl

;Break

:Default

4
;"Cout << “The student failed

;Break

;Return 0

-NUMBER odd - 3

>include <iostream#

;Using namespace std

)(Int main

{For(int i=1;i<=100;i++)

{If(i%2!=0)

;Cout<<i<<” its odd”<<endl

;Return 0

-EVEN NUMBERS -4

>include <iostream#

;Using namespace std

)(Int main

{For(int i=1;i<=100;i++)

5
{If(i%2==0)

;Cout<<i<<” its even”<<endl

;Return 0

You might also like