لإيجاد مساحة المثلث
Code:
#include <iostream.h>
#include <math.h>
main()
{
float a,b,c,s,area ;
cout << "\n Please enter A,B,andC: " ;
cin >> a>> b>> c ;
s = (a+b+c)/2 ;
area =sqrt(s*(s-a)*(s-b)*(s-c)) ;
cout << "\n Area = " << area ;
}
Printable View
لإيجاد مساحة المثلث
Code:
#include <iostream.h>
#include <math.h>
main()
{
float a,b,c,s,area ;
cout << "\n Please enter A,B,andC: " ;
cin >> a>> b>> c ;
s = (a+b+c)/2 ;
area =sqrt(s*(s-a)*(s-b)*(s-c)) ;
cout << "\n Area = " << area ;
}
لإيجاد المضروب (( الفيكتوريا )) طريقة 1
Code:
#include <iostream.h>
main()
{
int number, counter, fact ;
cout << "\n Please enter a number " ;
cin >> number ;
if (number<0)
cout << " negative number " ;
else
if (number==0)
cout << "Factorial of 0 = 1" ;
else
if (number==0)
cout << "factorial of 0 = 1 " ;
else
fact = 1 ;
for (counter=1; counter<=number; counter++)
{fact = fact *counter ;}
cout << "\n FACTORIAL OF " << number << " = "<< fact ;
}
الطريقة التقليدية لإيجاد الفيكتوريا (( المضروب ))
Code:
#include <iostream.h>
main()
{
int factorial = 1, dec = 7 ;
factorial *= dec ;
factorial *= ( --dec) ;
factorial *= ( --dec) ;
factorial *= ( --dec) ;
factorial *= ( --dec) ;
factorial *= ( --dec) ;
factorial *= ( --dec) ;
cout << "The factorial :\n (7)! = " << factorial ;
return 0 ;
}
برنامج ثلاتي لإيجاد مساحة كل من المثلت/ الدائرة / المربع
Code:
#include <iostream.h>
#include <math.h>
#include <conio.h>
main()
{ go: clrscr();
int choice ;
float a, b, c, s, area, r ;
/*the main menu*/
cout << " Main menu " ;
cout << " \n 1....Triangle" ;
cout << " \n 2....Circle" ;
cout << " \n 3....Square" ;
cout << " \n Enter your choice " ;
cin >> choice ;
switch(choice)
{
case 1:
cout << " \n Please enter A, B, and C: " ;
cin >> a>> b>> c ;
s = (a+b+c) / 2 ;
area = sqrt(s*(s-a)*(s-b)*(s-c)) ;
cout << " \n Area = " << area ;
break ;
case 2:
cout << "Enter the radius " ;
cin >> r ;
area = 3.14* r* r ;
cout << "\n Area = " << area<< " Squared unit" ;
break ;
case 3:
cout << "Enter the length of the square " ;
cin >> r ;
area = r* r ;
cout << "\n Area = " << area<< " Squared unit" ;
break ;
default:
goto go;
}
getch();
}
برنامج يحوّل من المساحة من الأقدام الى نظام الفدان
Code:
#include <iostream.h>
#include <stdio.h>
main()
{
float width ,length ,area ;
cout << "Please enter the width and length in feet\n" ;
cin >> width>> length ;
area = (length *width) /43560 ;
printf("The result area in acres = %8.2f acres" ,area ) ;
}
برنامج الساعه
Code:
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <graphics.h>
#include <conio.h>
#include <time.h>
#include <dos.h>
#include <stdlib.h>
#define PI 3.14159265359
#define _2PI 2*PI
#define IS_OK_SELECTED(x,y,button) (((x>=200)&&(x<=270)) && ((y>=418)&&(y<=443)) && ((button&1)==1))?1:0
#define IS_CANCEL_SELECTED(x,y,button) (((x>=370)&&(x<=440)) && ((y>=418)&&(y<=443)) && ((button&1)==1))?1:0
#define IS_HRUP_SELECTED(x,y,button) (((x>=238)&&(x<=250)) && ((y>=370)&&(y<=380)) && ((button&1)==1))?1:0
#define IS_HRDN_SELECTED(x,y,button) (((x>=238)&&(x<=250)) && ((y>=381)&&(y<=390)) && ((button&1)==1))?1:0
#define IS_MNUP_SELECTED(x,y,button) (((x>=303)&&(x<=315)) && ((y>=370)&&(y<=380)) && ((button&1)==1))?1:0
#define IS_MNDN_SELECTED(x,y,button) (((x>=303)&&(x<=315)) && ((y>=381)&&(y<=390)) && ((button&1)==1))?1:0
#define IS_SCUP_SELECTED(x,y,button) (((x>=368)&&(x<=380)) && ((y>=370)&&(y<=380)) && ((button&1)==1))?1:0
#define IS_SCDN_SELECTED(x,y,button) (((x>=368)&&(x<=380)) && ((y>=381)&&(y<=390)) && ((button&1)==1))?1:0
#define IS_APUP_SELECTED(x,y,button) (((x>=428)&&(x<=440)) && ((y>=370)&&(y<=380)) && ((button&1)==1))?1:0
#define IS_APDN_SELECTED(x,y,button) (((x>=428)&&(x<=440)) && ((y>=381)&&(y<=390)) && ((button&1)==1))?1:0
class coordinate
{
protected:
int x,y; public:
coordinate()
{
x=y=0;
}
coordinate(int initx,int inity)
{
x = initx;
y = inity;
}
};
class timenow
{
private:
struct time tm;public:
int tellhour(void)
{
gettime(&tm);
return tm.ti_hour;
}
int tellminute(void)
{
gettime(&tm);
return tm.ti_min;
}
int tellsecond(void)
{
gettime(&tm);
return tm.ti_sec;
}
};
class mouse
{
private:
union REGS i,o;
public:
mouse()
{
initmouse();
showmousepointer();
setmouseptrpos(425,320);
restrictmousepointer(1,1,630,478);
}
void initmouse()
{
i.x.ax = 0;
int86(0x33,&i,&o);
if(o.x.ax == 0)
{
cleardevice();
closegraph();
restorecrtmode();
printf("\nMouse driver not installed.\nQuitting...\n");
}
}
void showmousepointer()
{
i.x.ax = 1;
int86(0x33,&i,&o);
}
void setmouseptrpos(int row, int col)
{
i.x.ax = 4;
i.x.cx = col;
i.x.dx = row;
int86(0x33,&i,&o);
}
void hidemousepointer()
{
i.x.ax = 2;
int86(0x33,&i,&o);
}
void getmousepos(int &button, int &x, int &y)
{
i.x.ax = 3;
int86(0x33,&i,&o);
button = o.x.bx;
x = o.x.cx;
y = o.x.dx;
}
void restrictmousepointer(int x1, int y1, int x2, int y2)
{
i.x.ax = 7;
i.x.cx = x1;
i.x.dx = x2;
int86(0x33,&i,&o);
i.x.ax = 8;
i.x.cx = y1;
i.x.dx = y2;
int86(0x33,&i,&o);
}
};
class textbox
{
public:
textbox(int col1,int row1, int col2, int row2)
{
setfillstyle(SOLID_FILL,WHITE);
bar(col1,row1,col2,row2);
setcolor(LIGHTGRAY);
line(col1 + 1,row2-1,col2-1,row2-1);
line(col2-1,row1+1,col2-1,row2-1);
setcolor(DARKGRAY);
line(col1,row1-1,col2,row1-1);
line(col1-1,row1-1,col1-1,row2);
}
};
class BUTTON
{
private:
int row1,col1,row2,col2; public:
BUTTON()
{
}
BUTTON(int col1, int row1,int col2,int row2)
{
this -> col1=col1;
this -> row1=row2;
this -> col2=col2;
this -> row2=row2;
setcolor(BLACK);
rectangle(col1,row1,col2,row2);
setcolor(WHITE);
line(col1,row1,col2,row1);
line(col1,row1,col1,row2);
}
void Select(void)
{
setcolor(WHITE);
settextstyle(SANS_SERIF_FONT,0,1);
setcolor(BLACK);
line(this -> col1, this->row1,this->col2,this->row1);
line(this -> col1, this->row1,this->col1,this->row2);
setcolor(WHITE);
line(this -> col2, this->row1,this->col2,this->row2);
line(this -> col2, this->row2,this->col1,this->row2);
settextstyle(DEFAULT_FONT,0,1);
}
void UnSelect(void)
{
setcolor(BLACK);
settextstyle(SANS_SERIF_FONT,0,1);
setcolor(WHITE);
line(col1,row1,col2,row1);
line(col1,row1,col1,row2);
setcolor(BLACK);
line(col2,row1,col2,row2);
line(col2,row2,col1,row2);
settextstyle(DEFAULT_FONT,0,1);
}
};
class clockbody:public coordinate
{
private:
int radius; public:
clockbody(int centreX,int centreY):coordinate(centreX,centreY)
{
int inner_radius;
int i;
setcolor(WHITE);
settextstyle(TRIPLEX_FONT,0,1);
outtextxy(260,82,"TIME VIEWER");
radius = (200*8)/20;
inner_radius = (radius*8)/10;
setcolor(WHITE);
circle(x,y,radius);
setfillstyle(SOLID_FILL,LIGHTGRAY);
floodfill(x,y,getmaxcolor());
setcolor(WHITE);
circle(x,y,inner_radius-5);
setfillstyle(SOLID_FILL,WHITE);
floodfill(x,y,getmaxcolor());
setcolor(BLACK);
circle(x,y,1);
int row,col;
char no[5];
settextstyle(SANS_SERIF_FONT,0,1);
radius = 70;
settextstyle(DEFAULT_FONT,0,1);
for(i=1;i<=12;i++)
{
row = (x+radius*sin(_2PI*i/12.0));
col = (y-radius*cos(_2PI*i/12.0));
itoa(i,no,10);
outtextxy((row-textwidth(no)/2),(col+textheight(no)/2)-5,no);
}
}
int tellradius(void)
{
return radius;
}
int tellcentreX(void)
{
return x;
}
int tellcentreY(void)
{
return y;
}
};
void main(void)
{
int gd = DETECT,gm;
int hr,min,sec,acchr;
int button,x,y;
char strtime[3],opt;
struct time ot,nt;
static char apflg;
void frame(int,int,int,int);
void background(int,int,int,int);
void clockhands(int,int,int,clockbody,char);
char *putzero(char[]);
initgraph(&gd,&gm,"C:\\TC\\BGI");
cleardevice();
frame(190,125,450,350);
frame(190,70,450,120);
background(190,360,450,400);
background(190,410,450,450);
BUTTON hrup(238,370,250,380),hrdn(238,381,250,390),
mnup(303,370,315,380),mndn(303,381,315,390),
scup(368,370,380,380),scdn(368,381,380,390),
apup(428,370,440,380),apdn(428,381,440,390),
Ok(200,418,270,443),Cancel(370,418,440,443);
setcolor(BLACK);
outtextxy(240,371,"");outtextxy(305,371,"");
outtextxy(370,371,"");outtextxy(430,371,"");
outtextxy(240,382,"");outtextxy(305,382,"");
outtextxy(370,382,"");outtextxy(430,382,"");
outtextxy(230,428,"Ok");outtextxy(382,428,"Cancel");
textbox hour(200,370,235,390),minute(265,370,300,390),
second(330,370,365,390),ampm(390,370,425,390);
clockbody clock(getmaxx()/2,getmaxy()/2);
timenow time;
mouse m;
gettime(&ot);
setcolor(WHITE);
outtextxy(100,470,"Developed and Designed by Ranawat Mahipat Balwantraj, GCET.");
while(1)
{
hr = time.tellhour();
min = time.tellminute();
sec = time.tellsecond();
if(hr>=12)
apflg = 'p';
if(hr < 12)
apflg = 'a';
m.getmousepos(button,x,y);
if(IS_OK_SELECTED(x,y,button))
{
while(IS_OK_SELECTED(x,y,button))
{
Ok.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(230,428,"Ok");
}
Ok.UnSelect();
setcolor(BLACK);
outtextxy(230,428,"Ok");
gettime(&nt);
if(nt.ti_hour==0)
nt.ti_hour=12;
settime(&nt);
break;
}
if(IS_CANCEL_SELECTED(x,y,button))
{
while(IS_CANCEL_SELECTED(x,y,button))
{
Cancel.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(382,428,"Cancel");
}
Cancel.UnSelect();
setcolor(BLACK);
outtextxy(382,428,"Cancel");
settime(&ot);
break;
}
if(IS_HRUP_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_HRUP_SELECTED(x,y,button))
{
hrup.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(240,371,"");
}
hrup.UnSelect();
nt.ti_hour++;
if(nt.ti_hour>23)
nt.ti_hour = 12;
else if(nt.ti_hour > 11 && nt.ti_hour < 13)
nt.ti_hour = 0;
settime(&nt);
hr = time.tellhour();
setcolor(BLACK);
outtextxy(240,371,"");
}
if(IS_HRDN_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_HRDN_SELECTED(x,y,button))
{
hrdn.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(240,382,"");
}
hrdn.UnSelect();
if(nt.ti_hour < 1 && apflg == 'a')
nt.ti_hour = 12;
nt.ti_hour--;
if(nt.ti_hour < 12 && apflg == 'p')
nt.ti_hour = 23;
else if(nt.ti_hour < 1 && apflg =='a')
nt.ti_hour = 0;
settime(&nt);
hr = time.tellhour();
setcolor(BLACK);
outtextxy(240,382,"");
}
if(IS_MNUP_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_MNUP_SELECTED(x,y,button))
{
mnup.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(305,371,"");
}
mnup.UnSelect();
nt.ti_min++;
if(nt.ti_min > 59)
nt.ti_min = 0;
min = time.tellminute();
settime(&nt);
setcolor(BLACK);
outtextxy(305,371,"");
}
if(IS_MNDN_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_MNDN_SELECTED(x,y,button))
{
mndn.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(305,382,"");
}
mndn.UnSelect();
nt.ti_min--;
if(nt.ti_min == 0)
nt.ti_min = 59;
settime(&nt);
min = time.tellminute();
setcolor(BLACK);
outtextxy(305,382,"");
}
if(IS_SCUP_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_SCUP_SELECTED(x,y,button))
{
scup.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(370,371,"");
}
scup.UnSelect();
nt.ti_sec++;
if(nt.ti_sec > 59)
nt.ti_sec = 0;
settime(&nt);
sec = time.tellsecond();
setcolor(BLACK);
outtextxy(370,371,"");
}
if(IS_SCDN_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_SCDN_SELECTED(x,y,button))
{
scdn.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(307,382,"");
}
scdn.UnSelect();
nt.ti_sec--;
if(nt.ti_sec == 0)
nt.ti_sec = 59;
min = time.tellminute();
settime(&nt);
sec = time.tellminute();
setcolor(BLACK);
outtextxy(305,382,"");
}
if(IS_APUP_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_APUP_SELECTED(x,y,button))
{
apup.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(430,371,"");
}
apup.UnSelect();
setcolor(BLACK);
outtextxy(430,371,"");
switch(apflg)
{
case 'a': nt.ti_hour += 12;
settime(&nt);
break;
case 'p': nt.ti_hour -= 12;
settime(&nt);
break;
}
settime(&nt);
}
if(IS_APDN_SELECTED(x,y,button))
{
gettime(&nt);
while(IS_APDN_SELECTED(x,y,button))
{
apdn.Select();
m.getmousepos(button,x,y);
setcolor(WHITE);
outtextxy(430,382,"");
}
apdn.UnSelect();
setcolor(BLACK);
outtextxy(430,382,"");
switch(apflg)
{
case 'a': nt.ti_hour += 12;
settime(&nt);
break;
case 'p': nt.ti_hour -= 12;
settime(&nt);
break;
}
settime(&nt);
}
setcolor(BLACK);
if(hr == 0)
acchr = 12;
else if(hr>12)
acchr = hr-12;
else
acchr = hr;
if(hr>=12)
setcolor(WHITE),outtextxy(400,375,"AM"),
setcolor(BLACK),outtextxy(400,375,"PM"),
apflg = 'p';
else
setcolor(WHITE),outtextxy(400,375,"PM"),
setcolor(BLACK),outtextxy(400,375,"AM"),
apflg = 'a';
outtextxy(210,375,putzero(itoa(acchr,strtime,10)));
outtextxy(275,375,putzero(itoa(min,strtime,10)));
outtextxy(340,375,putzero(itoa(sec,strtime,10)));
opt='n';
clockhands(hr,min,sec,clock,opt);
delay(50);
setcolor(WHITE);
outtextxy(210,375,putzero(itoa(acchr,strtime,10)));
outtextxy(275,375,putzero(itoa(min,strtime,10)));
outtextxy(340,375,putzero(itoa(sec,strtime,10)));
opt = 'y';
clockhands(hr,min,sec,clock,opt);
}
closegraph();
restorecrtmode();
}
char* putzero(char strtime[])
{
if(strlen(strtime) == 1)
{
strtime[1] = strtime[0];
strtime[0] = '0';
strtime[2] = '\0';
}
return strtime;
}
void clockhands(int h, int m,int s,clockbody clock,char opt)
{
int x = clock.tellcentreX();
int y = clock.tellcentreY();
int r = clock.tellradius();
int h_len = (r*5)/10;
int m_len = (r*7)/10;
int s_len = (r*6)/10;
double hour_value = h+m/60.0 + s/3600.00;
hour_value *= _2PI/12.0;
if(opt!='y')
setcolor(BLACK);
setlinestyle(0,0,3);
line(x,y,(int)(x+h_len*sin(hour_value)),(int)(y-h_len*cos(hour_value)));
line(x,y+1,(int)(x+h_len*sin(hour_value)),(int)(y-h_len*cos(hour_value))+1);
double minute_value = m+ s/60.0;
minute_value *= _2PI/60.0;
if(opt!='y')
setcolor(BLACK);
setlinestyle(0,0,3);
line(x,y,(int)(x+m_len*sin(minute_value)),(int)(y-m_len*cos(minute_value)));
line(x,y+1,(int)(x+m_len*sin(minute_value)),(int)(y-m_len*cos(minute_value))+1);
double second_value = s*_2PI/60.0;
minute_value *= _2PI/60.0;
if(opt!='y')
setcolor(BLACK);
setlinestyle(0,0,1);
line(x,y,(int)(x+s_len*sin(second_value)),(int)(y-s_len*cos(second_value)));
}
void background(int c1,int r1, int c2, int r2)
{
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(c1,r1,c2,r2);
setcolor(WHITE);
line(c1,r1,c2,r1);
line(c1,r1+1,c2,r1+1);
line(c2,r1,c2,r2);
line(c2-1,r1,c2-1,r2);
setcolor(DARKGRAY);
line(c1,r1,c1,r2);
line(c1+1,r1,c1+1,r2);
line(c1,r2,c2,r2);
line(c1,r2-1,c2,r2-1);
}
void frame(int c1,int r1,int c2,int r2)
{
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(c1,r1,c2,r2);
setcolor(WHITE);
setfillstyle(SOLID_FILL,BLACK);
bar(c1+15,r1+15,c2-15,r2-15);
setcolor(WHITE);
line(c1,r1,c2,r1);
line(c1,r1+1,c2,r1+1);
line(c2,r1,c2-1,r2);
line(c1+15,r1+15,c1+15,r2-15);
line(c1+15,r2-15,c2-15,r2-15);
line((c1+15)-1,r1+15,(c1+15)-1,r2-15);
line((c1+15)-1,(r2-15)+1,c2-15,(r2-15)+1);
setcolor(DARKGRAY);
line(c1+15,(r1+15)-1,c2-15,(r1+15)-1);
line(c1+15,(r1+15)-2,c2-15,(r1+15)-2);
line(c1,r1,c1,r2);
line(c1+1,r1,c1+1,r2);
line(c1,r2,c2,r2);
line(c1+1,r2-1,c2,r2-1);
}
برنامج لإيجاد المصفوفة الثنائية
Code:
#include <iostream.h>
main()
{
float a[2][3], b[2][3] ;
int i, j ;
cout << "\n \a Please enter the elements: " ;
for(i=0; i<2; i++)
for(j=0; j<3; j++)
{
cout << "\n A[ "<< i+1<< " , "<< j+1 << " ] = " ;
cin >> a[j] ;
cout << "\t B[ "<< i+1<< " , "<< j+1 << " ] = " ;
cin >> b[j] ;
}
for(i=0; i<2; i++)
{
for(j=0; j<3; j++)
cout << a[j]+b[j] << "\t" ;
cout << '\n' ;
}
}
ضرب مصفوفتين ثنائيتين
Code:
#include <iostream.h>
main()
{
int a[5][5], b[5][5], c[5][5] ;
int temp, m, p, n, i, j, k ;
cout << "\nEnter number of row of 1st matrix\n" ;
cin >> m ;
cout << "\nEnter number of columns of 1st matrix\n" ;
cin >> p ;
cout << "\nEnter number of columns of 2nd matrix\n" ;
cin >> n ;
for(i=1;i<=m;i++)
for(j=1;j<=p;j++)
{
cout << "a["<< i<< "]["<< j<<"]=" ;
cin >> a[j] ;
}
cout << "\n" ;
for(i=1; i<=p; i++)
for(j=1; j<=n; j++)
{
cout << "b["<< i<< "]["<< j<< "]=" ;
cin >> b[j] ;
}
for(i=1; i<=m; i++)
for(j=1; j<=n; j++)
{
temp = 0 ;
for(k=1; k<=p; k++)
temp += a[k]* b[k][j] ;
c[j] = temp ;
}
cout << "\nThe multiplication is\n" ;
for(i=1; i<=m; i++)
{
for(j=1; j<=n;j++)
cout << c[j]<< " " ;
cout << "\n" ;
}
}
برنامج تذخل فيه 7 أرقام يقوم بترتيبها من الأكبر الى الأصغر
Code:
#include <iostream.h>
#include <stdio.h>
main()
{
short i, j, max, temp, number[7] ;
for(i=1; i<=7; i++)
{
printf("Please enter the number (%d) : ", i) ;
cin >> number ;
}
for(i=2; i<=7; i++)
if(number>max)
max = number ;
cout << "The maximum number of the numbers = "<<max ;
for(i=1; i<=6; i++)
{
for(j=i+1; j<=7; j++)
{
if(number[j]>number)
{
temp = number ;
number = number[j] ;
number[j] = temp ;
}
}
}
cout << "\nThe numbers are arranged as : \n\t " ;
for(i=1; i<=7; i++)
cout << number << "\t" ;
}
برنامج تعطية إحداثياث عمودين في الرسم البياني ويعطيك ما إذا كانا متوازيان أو متقاطعان في نقطة يقوم بذكر تلك النقطة
Code:
#include <iostream.h>
#include <math.h>
main()
{
float a1, a2, b1, b2, c1, c2, d, d_x, d_y, x, y ;
cout << "\nEnter the cofactor of the first line " ;
cin >> a1>> b1>> c1 ;
cout << "\nEnter the cofactor of the second line " ;
cin >> a2>> b2>> c2 ;
d = (a1*b2) - (a2*b1) ;
d_x = (c1*b2) - (c2*b1) ;
d_y = (a1*c2) - (a2*c1) ;
if(d==0)
cout << "\nThis two lines are parallel " ;
else
{
x = d_x / d ;
y = d_y / d ;
cout << "\nThe intersection point of your lines are :("<< x<<","<< y<<")" ;
}
}
برنامج حسابات لمستشفى
Code:
#include <iostream.h>
#include <conio.h>
main()
{
int n ;
char request ;
float sc, mc, misc, dayc, id, total, total_id, total_md ;
begin: clrscr() ;
cout << "\n\nPlease enter Number of days the patient set in hospital : " ;
cin >> n ;
cout << "Please enter Surgery coast : " ;
cin >> sc ;
cout << "Please enter Medication coast : " ;
cin >> mc ;
cout << "Please enter Miscellaneous coast : " ;
cin >> misc ;
cout << "Please enter Coast in hospital per day : " ;
cin >> dayc ;
cout << "Please enter Insurance deductible : " ;
cin >> id ;
total = (dayc* n) + sc + mc + misc + id ;
cout << "Total coast : " << total ;
total_id = total - id ;
cout << "\nTotal coast LESS Insurance deductible : " << total_id ;
total_md = total - mc ;
cout << "\nTotal coast LESS Medication & deductible : " << total_md ;
cout << "\nDo you have another patient (Y/N) : " ;
cin >> request ;
if(request=='y') goto begin ;
}
حل لهذه المعادلة aX^2+bX+c=0
Code:
#include <iostream.h>
#include <math.h>
main()
{
int a, b, c ;
float mezo, rule, rule_1, rule_2 ;
cout << "TO SOLVE THE QUADRATIC EQUATION: \n\t aX^2+bX+c=0 \n" ;
cout << "PLEASE ENTER a, b ,and c: " ;
cin >> a>> b>> c ;
mezo = b^2 - (4* a* c) ;
if(mezo==0)
{
rule = (-b) / (2* a) ;
cout << "THE ROOTS ARE:\n\t\t" << rule << "\n\t\t" << rule ;
}
else
if(mezo<0)
{
mezo = -mezo ;
rule_1 =(-b)/(2* a) ;
rule_2 = sqrt(mezo)/(2* a) ;
cout << "THE ROOTS ARE :\n\t\t" << rule_1<< " + "<< rule_2<< " i" ;
cout << "\n\t\t" << rule_1<< " - "<< rule_2<< " i" ;
}
else
{
rule_1 = ((-b)+ sqrt(mezo)) / (2* a) ;
rule_2 = ((-b)- sqrt(mezo)) / (2* a) ;
cout << "The roots are:\n\t\t"<< rule_1<< "\n\t\t"<< rule_2 ;
}
cin>>"";
}