A Summary of C++ syntax for beginners, in Arabic.
This document was originally sketched on paper, and meticulously converted into Powerpoint by FCIS student Eman Reda
الفصل الرابع الأعلان عن الإجراء Sub
الاجراء ( procedure )
هو مجموعة من الاوامر و التعليمات ( code ) تحت اسم ما عند استدعاء هذا الاسم يتم تنفيذ هذه الاوامر و التعليمات
A Summary of C++ syntax for beginners, in Arabic.
This document was originally sketched on paper, and meticulously converted into Powerpoint by FCIS student Eman Reda
الفصل الرابع الأعلان عن الإجراء Sub
الاجراء ( procedure )
هو مجموعة من الاوامر و التعليمات ( code ) تحت اسم ما عند استدعاء هذا الاسم يتم تنفيذ هذه الاوامر و التعليمات
In this lecture, I present concept of arrays in C ++ , I cover :
- Arrays defination
- Initializing arrays
- Input and output with arrays
- Examples of arrays
- Histogram using arrays
- Calculate the frequency of dice
- Calculate the frequency of characters in a string
- Static arrays
- Arrays as arguments
- Two-dimensional arrays
In this lecture, I present concept of functions in C ++ , I cover :
-The concept of functions
-Function template and definition
-Explanation of an example of a Factorial function
-Mathematical examples
-Empty arguments
-Function of perfect number
-Function of prime number
-Function of friendly numbers
-Generate random numbers
-Example of dice game
-GRN problems
-Time function
-Enumeration
-Crops game
-The concept of recursion function
-Example of recursion function
-Fibonacci series with recursion
-Reference arguments
-Default arguments
-Overloading functions
-Examples of overloading
-Template functions
The outlines of this lecture:
- Memory Addresses in Computer
- Definition of Pointers
- Access to Pointer Value
- star and & Operators
- Passing Pointer as Parameters
- Pointers with Constants
- Pointers with String
- Arrays of Pointers
- cString library
- Exercise
In this lecture, I present concept of arrays in C ++ , I cover :
- Arrays defination
- Initializing arrays
- Input and output with arrays
- Examples of arrays
- Histogram using arrays
- Calculate the frequency of dice
- Calculate the frequency of characters in a string
- Static arrays
- Arrays as arguments
- Two-dimensional arrays
In this lecture, I present concept of functions in C ++ , I cover :
-The concept of functions
-Function template and definition
-Explanation of an example of a Factorial function
-Mathematical examples
-Empty arguments
-Function of perfect number
-Function of prime number
-Function of friendly numbers
-Generate random numbers
-Example of dice game
-GRN problems
-Time function
-Enumeration
-Crops game
-The concept of recursion function
-Example of recursion function
-Fibonacci series with recursion
-Reference arguments
-Default arguments
-Overloading functions
-Examples of overloading
-Template functions
The outlines of this lecture:
- Memory Addresses in Computer
- Definition of Pointers
- Access to Pointer Value
- star and & Operators
- Passing Pointer as Parameters
- Pointers with Constants
- Pointers with String
- Arrays of Pointers
- cString library
- Exercise
El colegio de tu hijo/a te pide, como profesional del protocolo y como miembro AMPA, que organices una mesa redonda dirigida a los padres y madres del alumnado. El tema que se abordará será: El uso de redes sociales en educación. Acudirá el concejal de educación y cultura de tu localidad.
Para todo ello te piden:
- Que solicites el salón de la Casa de la Cultura de tu localidad, para un día y hora en concreto, a través de un email dirigido a la persona competente.
- Diseño de las invitaciones tanto para los padres y madres, como para los expositores- expertos en el tema, el moderador y el concejal de educación y cultura.
- Ordenación de la mesa con las personalidades invitadas utilizando la cesión de presidencia moderna.
¡¡¡Ojo, por cierto!!!, a última hora el moderador te informa que no podrá acudir, ¿qué hacemos ahora?
هل ترغب بانجاز عملك بوقت أقل؟
هل تريد أن تصنع نوع التفاعلية مع المستخدمين؟
هل ترغب بأن يكون موقعك محاكي لما يقوم به المستخدم؟
هل ترغب التحقق من البيانات عن طريق المتصفح قبل الخادم؟
هل ترغب بأمر سهل ..أسهل بكثير من الجافا سكربت؟
اذا تعال معنا للتعلم إحدى أقوى مكتباب الجافا سكربت
دورة جي كويري
قم بزيارة الموقع
2nees.com
لتحميل الملف مع كامل الأمثلة ...
(دورة مجانية)
1. hello word برنامج صغير لطباعة
#include <iostream>
int main()
{
cout << “Hello World!n”;
return 0;
}
Or
#include <iostream>
void main()
{
cout << “Hello World!n”;
}
هي دوال للطباعةvoid *تفضل الطريقة الثانية لن دوال
برنامج بسيط لدخال عددين وايجاد حاصل الجمع بينهما
#include <iostream>
int main()
{
int a,b,c;
cout << “enter the 1st No.n”;
cin>>a;
cout << “enter the 2nd No. n”;
c=a+b;
cout << “the result is ”<<c<<“n”;
return 0;
}
2. برنامج ليجاد مساحة ومحيط المستطيل
#include <iostream.h>
int main()
{
int width,length,area,circumference;
cout<<"Enter the width n";
cin>> width;
cout<<"Enter the length n";
cin>> length;
area= length*width;
circumference= (length+width)*2;
cout<<"The Arae is "<<area<<endl;
cout<<"The Circummference is "<<circumference<<endl;
return 0;
}
برنامج ليجاد مساحة ومحيط المربع
# include <iostream.h>
int main()
{
int length,Area,Circumference;
cout<<"Enter the length n";
cin>>length;
Area= length*length;
Circumference= 4*length;
cout<<"The Area is "<<Area<<"n";
cout<<"The Circumference is "<<Circumference<<"n";
return 0;
}
او غيرهاint *في هذه الصفحة تعلمنا ان هناك متغيرات نعرفها بنوعها
او كقانون ايint a =5 او بتخصيص مباشرcin ونخصص لها قيمة اما ب
ناتج لعملية مثل الجمع والضرب وغيرها
3. } ( if ( condition
statements
{
else
تعمل بتحقق والشرط وبخلفه ل تعملif الداة
if تعمل عند عدم تحقق شرطelse *الداة
برنامج لدخال درجة طالب لمعرفة هل الطالب ناجح ام راسب
#include <iostream.h>
int main()
{
int x;
cout<<"Enter the student mark ";
cin>>x;
if (x>=50)
cout<<"The the student pass the exam n";
else
cout<<"The the student fail in the exam n";
return 0;
}
4. (٢،٣،٥،٧) برنامج لدخال أي عدد وقابليته على القسمة
#include <iostream.h>
int main()
{
int x;
cout<<"Enter the value of x ";
if (x%2==0)
cout<<"The number is multiple of 2 n";
cin>>x;
if (x%3==0)
cout<<"The number is multiple of 3 n";
if (x%5==0)
cout<<"The number is multiple of 5 n";
if (x%7==0)
cout<<"The number is multiple of 7 n";
return 0;
}
*العملية % تعني قابلية القسمة وليست القسمة او النسبة المئوية
**ايعاز ليساوي هو
!=
5. برنا مج لدخال عدد ين وع مل ا حد العمليات الح سابية الب سيطة علي ها بكات بة
switch الرمز وباستخدام المر
#include<iostream.h>
int main()
{
int a,b;
char x;
cout<<"enter the value of X and Yn";
cin>>a>>b;
cout<<"+ for sumn";
cout<<"- for subn";
cout<<"/ for divn";
cout<<"* for multn";
cin>>x;
switch(x)
{
case '+':cout<<a+b;break;
case '-':cout<<a-b;break;
case '/':cout<<a/b;break;
case '*':cout<<a*b;break;
default:cout<<"error";break;
}
return 0;
}
6. برنام هج لدخال عدد ص هحيح ومعرف هة ه هل ان العدد
ه ه ه ه
زوجي ام فردي
#include<iostream.h>
Int main()
{
Int number;
Cout<<”enter the number u want to check it ”;
Cin>>number;
If (number > 0)
{
Cout<<”the number is positive n“;
If (number%2=0)
Cout<<”the number is evenn”;
Else
Cout<<”the number is oddn”;
}
Else
Cout<<”the number is negativen”;
Return 0;
}
برنامج لدخال عدد من ثلث مراتب وعكسه ومعرفة مموع مراتبه
#include<iostream.h>
int main()
{
int m,d,n=0,total=0;
7. cout<<"Enter the three digit number:"<<endl;
cin>>m;
while(m>0)
{
d=m%10;
total+=d;
m /=10;
n=10*n+d;
}
cout<<"The reverse three digit number is "<<n<<endl;
cout<<"Summation of three digits is "<<total<<endl;
return 0;
}
برنامج لدخال عشر عناصر ف مصفوفة وطباعتها
#include <iostream.h>
void main()
{
int n[10];
for (int i=0 ; i<10 ;i++)
{
cin>> n[i];
}
for (int j =0;j<10 ;j++)
{
cout<< n[j]<<endl;
}
#include <iostream>
void main()
{
int n[10]={88, 65,5555,4545,4345,354,454,344,3334};
for (int j =0;j<10 ;j)
8. {
;cout<<n[j]<<endl
}
سوينا لووب لدخال عناصر الصفوفة ولووب بالبنامج الول
.... اخر لخراج عن طريق سي ان و سي آوت
اما بالبنامج الثاني فادخلنا عناصر الصفوفة بصورة
مباشرة
الفنكشن
الكثير منا يضن ان الفنكشن باللغة السي بلس بلس هي ترف علمي او ليست لها فائدة
لكن في الحقيقة هي شيء مهم جدا لكن المثلة الي عليها تحسس الطالب انها ترف
علمي او ليست لها فائدة ...
لتخلص من هذه المشكلة يجب علينا التطلع في المثال التالي
يعني لو كانت لدينا شركة من الشركات في كل شركة هناك مدير للشركة هذا شي طبيعي
....السؤال هل ان المدير يقوم بكل اعمال الشركة ؟؟؟!!!
الجواب بالطبع كل
كل المدير من الطبيعي يحتاج الى مساعدين الى ادارين مترجمين، ومختصين بالمور
المالية ،اعلمين، مصممين و الى حراس ... الخ من هذه المهن
يمكن ان نقول ان الدالة الرئيسية ) (mainهي مدير الشركة و بقية الموظفين هم
الفنكشن .
مثل ما عودتنا لغة السي بلس بلس بمرونتها فممكن نكتب الفنكشن بعده طرق وحسب
الستخدام والحاجة ولتسهيل عمل المبرمج.
راح نكتب برامج لجمع عددين بالطريقة العادية وهذا المثال اخذنا في مرحلة سابقة
9. ونبدي نحولة الفنكش اتوقع الكلم غير مفهوم لحد الن لكن بعد قراءة المثال راح
تفتهمون شنو المقصود من كلمي ^_^
>#include <iostream
)(int main
{
;int a,b,c
;”cout << “enter the 1st No.n
;cin>>a
;”cout << “enter the 2nd No. n
;c=a+b
;”cout << “the result is ”<<c<<“n
;0 return
}
هنا خطية مدير الشركة هو ال كل الشغل عليه هو ال يب
معلومات وهو يشتغلها بيده وهو يطلع ناتج ترة ماكو هيج
مدير كل الشغل راسة ههههههههههه
راح نعي فد سكرتية للمدير تساعده خطية
:بالبامج التالية
>#include <iostream.h
)int sum (int l,int r
{
;int u
;u=l+r
;retrun u
}
)(int main
{
;int a,b
;”cout << “enter the 1st No.n
;cin>>a
;”cout << “enter the 2nd No. n
;cin>>b
;)cout << “the result is ”<<sum (a,b
;0 return
}
10. بالبنامج السابق السكرتية هي تي من وكت قبل الدير وهي
ترتب الكتب لكن هذه السكرتية ليست لديها الة الطابعة
...))سي آوت
الطابعة تكون ي الدير
#include <iostream.h>
void sum (int l,int r)
{
int u;
u=l+r;
cout << “the result is ”<<sum (a,b);
}
int main()
{
cout << “enter the 1st No.n”;
cin>>a;
cout << “enter the 2nd No. n”;
cin>>b;
sum (a,b);
return 0;
}
11. الالة السابقة راح تكون الة الطابعة ي السكرتية
خلي نشوف الفرق بي السكرتية الول والثانية
السكرتية الول تكن الدير من القيمة مالتها راح الدير
يكدر يستثمرها مرة ل بغي عملية حسابية
لكن السكرتية الثانية ليكن هذا الشي
يعن لو ان الدير اراد ان يضيف عدد ال عددين السابقي
المثلة التالية راح تفهمنا وية كل وحدة شلون نتعامل
>#include <iostream.h
)int sum (int l,int r
{
;int u
;u=l+r
;retrun u
}
12. int main()
{
int a,b,c;
cout << “enter the 1st No.n”;
cin>>a;
cout << “enter the 2nd No. n”;
cin>>b;
cout << “enter the 3rd No. n”;
cin>>c;
int n=sum (a,b);
cout<< n;
int m =sum (n,c); استخدمنا القيمة الراجعة مرة ل وراح
السكرترة تمع مرة ل
cout <<m;
return 0;
}
#include <iostream.h>
void sum (int l,int r)
{
int u;
u=l+r;
cout << “the result is ”<<sum (a,b);
}
int main()
{
cout << “enter the 1st No.n”;
cin>>a;
cout << “enter the 2nd No. n”;
cin>>b;
cout << “enter the 3rd No. n”;
cin>>c;
sum (a,b);
هنا انلصت لن ما اكدر اجع العدد الثالث
شفتوا الفرق يعن خلي ناخذ مثال ال السابقي
13. ;)sum (a,c
راح هم يطلع ثني ما سوينا شي
;0 return
}
فنستنتج ان الفويد فنكشن مثل الاعون الدوسبسبل يستخدم
مرة واحدة لكن الفنكشن ال يرجع قيمة مثل الاعون الفخار
نكدر نغسلة ونستخدمة مرة ل
ومكن نستفاد من قيمتة بغي عمليات رياضية
احنا نسينا سالفة قلنا سي بلس بلس مرنة واغلب الشياء
مسويتلها حلول يعن عينا سكرتايرات لكن نسينا اكو
سكرتيات يتعينن بالواسطة لو من معارف الدير هيج نوع تي
متاخرة عن الدير بالسي بلس بلس نسميها بروتو تايب
الدير شي يسوي ما يسجلها تاخي لن هاي واسطتها زينة
ما ياسبها.... الهم احنا راح ناخذ مثال على سكرتية تي
بعد الدير
>#include <iostream.h
هذا هو الفرق الوحيد عن البدون واسطة ;)int sum (int l,int r
بالسي بلس بلس نسمي هالشي اعلن عن وجود فنكشن
هنا عن فنكشن لا قيمة ليست فويد
)(int main
{
;int a,b
14. cout << “enter the 1st No.n”;
cin>>a;
cout << “enter the 2nd No. n”;
cin>>b;
cout << “the result is ”<<sum (a,b);
return 0;
}
int sum (int l,int r)
{
int u;
u=l+r;
retrun u;
}
#include <iostream.h>
void sum (int l,int r);
int main()
{
int a,b;
cout << “enter the 1st No.n”;
cin>>a;
cout << “enter the 2nd No. n”;
cin>>b;
sum (a,b);
return 0;
}
void sum (int l,int r)
{
int u;
u=l+r;
cout<<u;
}
15. من هذا نتعلم انو الفنكشن اذا اريد اسويها بروتو تايب بس اسوي اعلن للفنكشن
العلن هو رأس الفنكشن واخليله فارزة قبل الدالة الرئيسية
الستركجر
الستركجر هو تعريف جديد نعرفة للكومبايلر ومن
ثم نستخدمه فلزم نكتب الستركجر في بداية
البرنامج قبل اي دالة من الدوال )المين او
الفنكشن (...
الصيغة العامة له
السم الي نريد نسمي struct
{
16. المحتويات
;}
ناخذ مثال حتة تتوضح الصورة
>#include <iostream.h
{ struct Time
;int hours
;int minutes
;int seconds
;}
هنا عرفا الستكجر للكومبايلر وصار نكدر نستخدمة شلون
جاعة int
{ )(int main
;struct Time t
هنا كتب ستكجر وراه اسه وبعدين اخلي التغي
كبل وية
;int t
هسة نكول هو الستكجر هو واسة استخدمة انت بعن للفهم
طبعا هاي مو حقيقة
;struct time t;= int t
ادخال الستكجر لزم يكون جزء جزء اهم شغلة هاي
;cin >> t.hours >> t.minutes >> t.seconds
الخراج لزم يتم هم جزء جزء
;cout<< t.hours >> t.minutes >> t.seconds
17. return 0;
}
برنامج راح نربط بي الستكجر وية الفنكشن ونكتشف عدة
شغلت بكل مرة نستخدم فد شغلة شكل
#include <iostream>
// نعرف اشكال جديدة ال هي الستكجر ومتواه
struct Time {
int hours;
int minutes;
int seconds;
};
// بروتو تايب
int toSeconds(struct alarm );
int main() {
struct Time t;
while (cin >> t.hours >> t.minutes >> t.seconds) {
cout << "Total seconds: " << toSeconds(t) << endl;
}
return 0;
}
18. { )int toSeconds(sruct alarm
;int a=3600* alarm.hours + 60* alarm.minutes + alarm.seconds
;return a
}
بالبنامج السابق حولنا الوقت ال ثواني هسة اريد اجع
وقتي مثل واريد يبقى شلووووووووووووون
هنا ماطول مراح نغي صيغه الوقت ال وحدة معينة )ساعات
او دقايق او ثواني (يعن لزم اجع ساعات الول مع ساعات
الثاني ودقايق الول مع دقايق الثاني والثواني بالثواني
يعن كل جزء بال يشبها من الزء الثاني
>#include<iostream.h
{ struct time
;int hours
;int minutes
;int seconds
;}
الفنكشن
) struct time sumtime (sruct time alarm, sruct time lula
{
;struct time msi
; msi.hours= alarm.hours+ lula.hours
;msi. minutes = alarm. minutes + lula. minutes
;msi. seconds = alarm. seconds + lula. seconds
جعنا كل جزء بال يشبه
;return msi
}
الفيكة هنا انو الفنكشن ترجع ستكجر كامل بكل متوياتة
من قيم ت التغي عليها لذلك ماطول الفنكشن ترجع ستكجر
ال اسة تاي لزم اكتب فوك ستكت تاي وادورة اسم الفنكشن
{ )(int main
;struct time alarm , lula , t
19. cin >> alarm.hours >> alarm.minutes >> alarm.seconds
cin >> lula.hours >> lula.minutes >> lula.seconds
t = struct time sumtime (alarm, lula );
رجعناه كامل لكن الخراج الستكجر لزم جزء جزء
cout << t.hours << t.minutes << t.seconds ;
}
return 0;
}