|
التمرين الأول صفحة 100 : حدد مخرجات الجمل التالية
ملحوظة هامة: نلاحظ أنه يطبع ما بداخل علامات التنصيص
" " كما هو
|
الجملة
|
المخرجات
|
|
cout<< "C++ is "<< "powerful language "; |
C++ is powerful language
|
|
cout<< "1+2+3+4 "; |
1+2+3+4 |
|
cout<< "1 - 2 "<< "*"<< "5" |
1 - 2 *5 |
التمرين الثاني صفحة 100
: حدد الجمل الصحيحة والجمل الخاطئة في التالي
|
الجملة
|
صح/خطأ
|
|
cout >> "welcome"; |
خطأ
التصحيح :cout<<"welcome";
|
|
cout << "welcome ; |
خطأ
welcome عدم وجود علامة " بعد
cout << "welcome ";
|
|
cout >> "welcome c++"; |
خطأ
التصحيح cout << " welcom C++";
|
تمرين رقم 3 صفحة 100
#include<iostream.h>
main()
{
cout<<"My name is : Salem";
cout<<endl;// هذا الأمر يستخدم للإنتقال لسطر
جديد وبذلك ستطبع الجملة التالية على السطر الجديد
cout<<"I'm 17 years old"<<endl;
cout<<"I born in 4/1/1990";
}
تمررين رقم 5 صفحة 100
#include<iostream.h>
main()
{
cout<<" * "<<endl;//لاحظ أن المسافة بين علامتي التنصيص تؤخذ في الاعتبار
عند الطباعة وتعتبر حرف
cout<<" *** "<<endl;
cout<<"*****";
}
=================================
توضيح
المتغير : هو اسم موضع للتخزين في الذاكرة
x=3;مثال
ووضعت فيه قيمة عبارة عن 3x المخزن
اسمه
=================================
تمرين رقم 1 صفحة 112
#include<iostream.h>
int n; // للتصريح عن متغير يأخذ قيم صحيحة فقط
main()
{
cout<<"Type in an integer number :";
cin>>n;// لإدخال قيمة من لوحة المفاتيح تخزن فى المتغير
cout<<endl;
cout<<" The cube of "<< n << " is "<<n*n*n;
// لاحظ أن مكعب الرقم هو حاصل ضربه في نفسه 3 مرات
}
========================
تمرين رقم 2 صفحة 112
#include<iostream.h>
float r,m;
main()
{
cout<<"Type in Radius : ";
cin>>r;
cout<<endl;
m=2*3.14*r;
cout<<" The circumference of the circle = "<< m ;
}
لاحظ المتغيرات المستخدمة في البرنامج السابق
من النوع العشري لأننا سنضرب نصف القطر في 3.14
r
ترمز إلى نصف القطر
m
ترمز لمحيط الدائرة
==================
التمرين رقم 3 صفحة 113
ترمز إلى الدرجة الفهرنهيتية F
ترمز للدرجة المئوية M
#include<iostream.h>
float F,M;
main()
{
cout<<"Type in Celsius : ";
cin>>M;
cout<<endl;
F=M*(9/5.0)+32; // لاحظ أنني
كتبت المقام 5.0 بدلا من 5
cout<<" Fehrenheit = "<< F;
}
==============================
تمرين 5 صفحة 113
#include<iostream.h>
float r,d;
main()
{
cout<<" Type the number of ryals =";
cin>>r; // عدد الريالات القطرية المراد تحويلها
الى دينار
cout<<endl;
d=r/11.5; // لتحويل الريال الى دينار كويتي
cout<<" Kwaity denars= "<<d;
}
=========================
تمرين رقم 6 صفحة 113
#include<iostream.h>
float x,x1,y,y1,z,z1;
main()
{
cout<<" type in the price of ref. = ";
cin>>x;
x1=x*9/100.0 ;// ربح الثلاجة
cout<<endl;
cout<<" type in the price of TV. = ";
cin>>y;
y1=y*11/100.0; // ربح التليفزيون
cout<<endl;
cout<<" type in the price of washer. = ";
cin>>z;
z1=z*8/100.0; // ربح الغسالة
cout<<endl;
cout<<"Profit = "<<x1+y1+z1;
}
====================================
#include<iostream.h>
float GPA;
main()
{
cout<<" type in GPA = ";
cin>>GPA; // لإدخال معدل الطالب
if(GPA>=50)
{cout << "Passed";} // سيتم تنفيذها إذا كان
معدل الطالب أكبر من أو يساوى 50 ويكون ناجحا
else
{cout<< "Failed";} // سيتم تنفيذها إذا كان معدل الطالب أقل من 50ويكون
راسبا
}
===========================
تمرين رقم 2 صفحة 123
#include<iostream.h>
float age;
main()
{
cout<<" type in student age = ";
cin>>age; // لإدخال عمر الطالب
if(age>=18)
{cout << "You are UNIVERCITY student";}
else
{cout<< "You still in SCHOOL ";}
}
============================
تمارين الكتاب صفحة 128 الى صفحة 130
تمرن رقم 2 صفحة 128
#include<iostream.h>
char fletter,sletter;// للتصريح عن متغير سوف يأخذ قيمة
عبارة عن حرف واحد
main()
{
cout<<" enter the first letter = ";
cin>>fletter; //لإدخال الحرف الأول
cout<<endl;
cout<<" enter the secon letter = ";
cin>>sletter; // لإدخال الحرف الثاني
cout<<endl;
if(fletter == sletter)
cout << "Equal";
else
cout<< "Different ";
}
============================
تمرن رقم 3 صفحة 128
#include<iostream.h>
#include <cstring.h> //
String يجب استخدام هذه الجملة قبل تعريف متغير من النوع
string fword,sword; // التصريح عن متغيرين
main()
{
cout<<" enter the first word = ";
cin>>fword; // لإدخال الكلمة الأولي
cout<<endl;
cout<<" enter the second word = ";
cin>>sword; // لإدخال الكلمة الثانية
cout<<endl;
if(fword == sword)
cout << "Equal";
else
cout<< "Different ";
}
=========================
التمرين رقم 3 صفحة 141
#include<iostream.h>
int i,m;
main()
{
for(i=1; i<=100; i++){
m=i%5;
if (m==0) cout<< i<<endl;
}
}
..............................................
التمرين رقم 4 ص 141
#include<iostream.h>
int i,sum;
main()
{
for(i=0; i<=20; i=i+2){
sum=sum+i;
}
cout<< "sum= "<< sum;
}
...........................................
التمرين رقم 6 صفحة 141
#include<iostream.h>
int i,sum,m;
main()
{
sum=1;
cin>>m;
for(i=m; i>=1; i=i-1){
sum=sum*i;
}
cout<<sum;
}
|