Presentation is loading. Please wait.

Presentation is loading. Please wait.

 Bitwise operators  Loops ◦ For Loop ◦ While Loop  Exam Overview.

Similar presentations


Presentation on theme: " Bitwise operators  Loops ◦ For Loop ◦ While Loop  Exam Overview."— Presentation transcript:

1

2  Bitwise operators  Loops ◦ For Loop ◦ While Loop  Exam Overview

3  تتعامل مع الارقام الثنائية منفصلة وعددها ستة وهي :-  تتعامل مع القيم الصحيحة أو القيم الحرفية فقط  فمثلا &0111 oc &07 = 04 --  1100 SymbolMeaning &And |OR ^Exor >>Right shift <<Left shift ~Complement

4  تستخدم لإختبار ما إذا كان رقم ثنائي معين قيمته ”1“ أو “0“ فمثلا : Ch& 0x08 تحدد ما اذا كان b 3 في ch يساوي “1“ أو “0“  بالنسبة للمؤثر ” أو “ | يمكن استخدامه لضم ارقام ثنائية من أحرف مختلفة لتشكيل الحرف z من الحرفين x ، y كما يلي :- x1 = x & 0x0f x2 = y & 0xf0 z = x1 | x2 0 0 0 0 X1 X2 z

5  يمكن استخدام Exor للحصول على متمم أي رقم ثنائى في متغير كما يلي : ch = ch^0x08  للحصول على متمم b 3 في المتغير ch

6  ~0x03 = 0xFC  ~0x88 = 0x77

7  Example : ch >>3  أي إزاحة الى اليمين بما يوازى ثلاثة أرقام ثنائية. 80>>2 = 20 80>>7 = 1 F0>>4 = 0F بالمثل بالنسبة لمؤثر الإزاحة ناحية اليسار (<<)

8 /* Pogram Name : Ex10.c*/ #include #define TRUE 1 main() { int x1,x2; while (TRUE) { printf("\nEnter two numbers (ff or less)\n"); scanf("%x",&x1); scanf("%x",&x2); printf("\n\t%02x|%02x=%02x",x1,x2,x1|x2); printf("\n\t%02x&%02x=%02x",x1,x2,x1&x2); printf("\n\t%02x^%02x=%02x",x1,x2,x1^x2); } return 0; }

9 main() { int x1,x2; while (TRUE) { printf("\nEnter Hex number (ff or less)\n and No Of bits not exceed 8"); scanf("%x %d",&x1,&x2); printf("\n\tRight shift operation :%02x>>%02d=%02x", x1, x2, x1>>x2); printf("\n\tLeft shift operation :%02x << %02d =%02x“,x1,x2,x1<<x2); } return 0; }

10  الصورة العامة كما يلي : for(count = v1;count<vf; count=count+s) { loop statement }  وتضم صيغة ضبط القيمة الإبتدائية وصيغة الاختبار وصيغة زيادة العداد.

11 أبدأ القيمة الإبتدائية أختبر صلب الألتفاف زد العداد أخرج لا نعم

12 count = 0,total =0 count = 1,total =1 count = 2,total =3 count = 3,total =6 count = 4,total =10 count = 5,total =15 count = 6,total =21 count = 7,total =28 count = 8,total =36 count = 9,total =45 #include main() { int count; int total = 0; for (count =0;count <10;count++) { total +=count; printf("Count =%d total = %d\n",count,total); } Return 0; } Ex12.c

13 #include main() { int count; int total = 0; for (count =0;count <10;count++) { total +=count; printf("Count =%d total = %d\n",count++,total); } Return 0; } Count =0 total = 0 Count =2 total = 2 Count =4 total = 6 Count =6 total = 12 Count =8 total = 20 Ex12.c ++

14 #include main() { int n; for (n = 41;n<256;n++) printf("%3d=%c\t",n,n); } Ex13.c

15 main() { int cols; for(cols=1;cols<40;cols++) printf("%c",'\xDB'); } What is the expected output from this program? How can we draw C with this graphic char? How can we draw I with this graphic char?

16 Ex15.c main() { int cols,rows; for (rows = 1;rows<13;rows++) { for (cols=1;cols<13;cols++) printf("%4d",cols*rows); printf("\n"); } 1 2 3 4 5 6 7 8 9 10 11 12 2 4 6 8 10 12 14 16 18 20 22 24 3 6 9 12 15 18 21 24 27 30 33 36 4 8 12 16 20 24 28 32 36 40 44 48 5 10 15 20 25 30 35 40 45 50 55 60 6 12 18 24 30 36 42 48 54 60 66 72 7 14 21 28 35 42 49 56 63 70 77 84 8 16 24 32 40 48 56 64 72 80 88 96 9 18 27 36 45 54 63 72 81 90 99 108 10 20 30 40 50 60 70 80 90 100 110 120 11 22 33 44 55 66 77 88 99 110 121 132 12 24 36 48 60 72 84 96 108 120 132 144

17  الصيغة العامة هي :  مثال : while(Conditional Expression) { Loop statements } main() { int cols = 1; int rows = 1; while(rows<13) { cols = 1; while(cols<13) { printf("%4d",cols*rows); cols++; } printf("\n"); rows++; } Ex15_whi.c Ex16.c

18 #include main() { int count = 0; printf("Type a phrase:\n"); while(getche()!='\r') count++; printf("\n Character count is is %d", count); return 0; } Ex17.c Type a phrase: Zagazig University Character count is is 18 Note that: char ch; while((ch=getche())!=‘\r’) { } Equivalent to char ch=‘a’; While(ch!=‘\r’) { ch = getche(); }

19  عرف مواصفات عرض الحقل – احرف الأشكال وكيفية طباعتها – المؤثرات الارقام الثنائية – أدوات الربط الثنائية – دوال ادخال الأحرف وقارن بينها  اكتب برنامج بلغة ال C لاستقبال الاعداد التالية ثم اخراجها مرتبة كل ثلاثة اعداد في سطر واحد مقربة لأقرب رقمين عشريين مستخدماً ايعاز اخراج واحد. أتبع الاعداد بالمتوسط الحسابي لها مسبوقاً بالتمييز  The average of the numbers is:  أكتب برنامج بلغة ال C لرسم حرف T من مستطيلات مضيئة ( احدى عشر أفقية وخمسة رأسية ) على ان يكون في وسط السطر مباشرة  استنتج مايقوم به البرنامج التالى :...

20


Download ppt " Bitwise operators  Loops ◦ For Loop ◦ While Loop  Exam Overview."

Similar presentations


Ads by Google