You are on page 1of 3

# include <iostream>

# include <conio.h>
using namespace std;
void instruct (void);
void pause () ;
int main (
double numl, num2, sum, product,quotient;
//executable section;
instruct );
cout<<"Enter first number: ";
cin>>numl;
cout<<"Enter second number : =
cin>>num2 ;
sum=numl+num2;
product=numl*num2
quotient=numl/num2

cout<<"\nThe
sumof"<<nunl <<" and"<<num2<<"is"<<sum<<" \nThe
product
by"<<num2<<"is" <<product <<"\nThequotient
by"<<num2<<"is"<<quotient<<endl;
of"<<numl<<"multiplied
of"<<numl<<"divided
cout<<" \nThe
<<endl;
difference
of
the
follows:
two
number
is
as
if (numl==num2) cout<<numl<<"is equal to"<<num2<<endl;
if (num1 !=num2) cout<<numl<<"is not equal to"<<num2<<endl;
if
(numl<num2) cout<<numl<<"is less than"<<num2<endl;
if
(numl>num2) cout<<num1<<"is greater than"<<num2<<endl;
if
(numl<num2) cout<<numl<<"is
less
than
equal
or
to"<<num2<<endl;

(numl>num2) cout <<num1 << "is


if
greater
than
equal
IO
to"<<num2<<endl;
pause ();
return 0;
}
void instruct (void)
{
cout<<"Choose two whole numbers to input below. The program
the product, the difference,
numbers that have been
will\n"<<"then calculate the sum,
\n"<<"quotient of
and
the
the
two
input.\n"<<endl;
}
void pause ()
1/ Declaration section
1/ Executable section
cout<<"\nPress any key to continue..
getch ();
cout<<" \r";
cout<<"
cout<<"\r";
}

alpro 2

Gambarkan hasil running dari listing program beriku


# include <iostream.h>
# include <conio.h>
int mult (int x,int y)
int result:
result-0;
while (yf-0
result-result+x;
y y-1
return (result);
int main )
int x,yi
Cout<<"Enter two natural number: "<<endl;
fX<<UTO
cin3>y;
Cout<<x<<"
getch ()
<mult (x, y)<<endl;

alpro 3

Gambarkan asil running dari listing program berikut! (30)


# include <iostream.h>
9 inclode <conio.h>
int main )
int A(10) [101,m,n,x,y,SU0
coutc Enter number of rows and columns in Matrik A
cin>>n>>m;
Cout<< Enter elements of Hatrik Ai \n
for (x-1ix<n+1;++x}
for (y-liycm+11++y
cin>>A[x] [yl
l/ind sum of each row
for (x-11x<n+1;++x)
A x] [m+1]=0
for (y-1rycm+11++y)
A[x] [m+1]-A[x] (m+1J+A[x] [ly
//tind sum of each colun
(y=11ycm+1;++y)
1
A[n+1] (y)-0;
for (x-1xn+1;++x}
A[n+1] [y]+-A ( X) [y];
coutc nMatrik A, Row Sum (Last Column)"<<"and Column Sun La
Row): \n"i
for (x-11x<n+1;++x)
for (y-1iy<m+2++y)
cout<CA[x] [y]<<" #}
cout<<An"
(U
(+4x1+>Xi [=X] 0
(++617+>&/T) 303
(A ) 3
cout<<s of diagonal elements ist"<sUEendl
getch ()
return 0

You might also like