1) اكتب برنامج لحساب وطباعة مساحة دائرة (area = PI * r * r)ومحيطها
(circumference
= 2 * PI * r).
إذا
علمت أن نصف قطرها (r)
يساوي 5.2 وأن PI =
3.1415926
#include <iostream.h>
main()
{
float
r, PI;
r
= 5.2;
PI
= 3.1415926;
cout<<"area
= "<< PI * r * r<<"\n";
cout<<"circumference
= "<< 2 * PI * r;
}
2) اكتب برنامج لإدخال طول (length)
وعرض (width) مستطيل.
ويحسب
ويطبع حافة المستطيل (perimeter = 2*(length+width) ) ومساحته (area=length*width)
#include <iostream.h>
main()
{
int
length, width;
cout<<"length
= "; cin>>length;
cout<<"width
= "; cin>>width;
cout<<"perimeter
= "<<2*(length+width)<<"\n";
cout<<"area
= "<<length*width;
}
3 ) اكتب برنامج لقراءة درجات أربع مواد (m1, m2, m3, m4)
ثم يحسب ويطبع المعدل ( avg = (m1+m2+m3+m4)/4 )
#include <iostream.h>
main()
{
int
m1, m2, m3, m4;
cout<<"Enter
marks \n";
cin>>m1>>m2>>m3>>m4;
cout<<"avg
= "<< (m1+m2+m3+m4)/4;
}
4 ) اكتب برنامج لطباعة اسمك في السطر الأول من الجهة اليسرى، وعنوانك في وسط السطر الثالث، والجنسية في الجهة اليمنى
#include <iostream.h>
main()
{
cout<<"Abdulla
Awad \n\n\t\t\t";
cout<<"BaitBoss
zone \t\t\t Yemeni";
}
5) اكتب برنامج يقرأ درجة الحرارة بالفهرانهايت ((f، ثم يحسبها بالمئوية ( c=
(f-32)*5/9 )
ويطبعها
#include <iostream.h>main(){ float f; cout<<"f = "; cin>>f; cout<<"c = "<< (f-32)*5.0/9.0;}
6
اكتب برنامج يقرأ درجة الحرارة بالمئوية (c)، ثم يحسبها بالفهرانهايت ( f= c*9/5+32) ) ويطبعها
#include <iostream.h>main(){ float
c; cout<<"c
= "; cin>>c; cout<<"f
= "<< c*9.0/5.0+32;}
7) اكتب برنامج يقرأ العجلة الثابتة (a)
والزمن (t)، ثم يحسب ويطبع المسافة d=0.5*a*pow(t,2) ) والسرعة النهائية ( v=a*t )
<include <iostream.h#
#include <math.h>
main()
{
float
a, t;
cout<<"a
= "; cin>>a;
cout<<"t
= "; cin>>t;
cout<<"d
= \n"<< 0.5*a*pow(t,2);
cout<<"v
= "<< a*t;
}
8 ) اكتب برنامج يقرأ عددين صحيحين (a,b)
وبرتبهما تصاعدياُ (إذا كان الأول أكبر من الثاني بدل بين قيمتهما)
#include <iostream.h>
main()
{
int
a, b, t;
cout<<"a
= "; cin>>a;
cout<<"b
= "; cin>>b;
if(a>b)
{
t=a;
a=b; b=t;
}
cout<<a<<"
"<<b;
}
7) اكتب برنامج يقرأ العجلة الثابتة (a)
والزمن (t)، ثم يحسب ويطبع المسافة d=0.5*a*pow(t,2) ) والسرعة النهائية ( v=a*t )
<include <iostream.h#
#include <math.h>
main()
{
float
a, t;
cout<<"a
= "; cin>>a;
cout<<"t
= "; cin>>t;
cout<<"d
= \n"<< 0.5*a*pow(t,2);
cout<<"v
= "<< a*t;
}
8 ) اكتب برنامج يقرأ عددين صحيحين (a,b)
وبرتبهما تصاعدياُ (إذا كان الأول أكبر من الثاني بدل بين قيمتهما)
#include <iostream.h>
main()
{
int
a, b, t;
cout<<"a
= "; cin>>a;
cout<<"b
= "; cin>>b;
if(a>b)
{
t=a;
a=b; b=t;
}
cout<<a<<"
"<<b;
}
Aucun commentaire:
Enregistrer un commentaire