Another View of Night




Factorial using Recursion Method

#include <iostream>
#include <conio.h>

using namespace std;

int calc (int x)
{
if (x==1)
{
return 1;
}
else
{
return (x * calc (x-1));
}
}

class factorial
{
private :
int number,fact,temp;

public :
void input ();
void proses ();
void output ();
}

int main ()
{
factorial f;

f.input ();
f.proses ();
f.output ();

getche ();
return 0;
}

void factorial :: input ()
{
cout << "input number = ";
cin >> number;
temp = number;
}
void factorial :: proses ()
{
fact = calc (temp);
}
void factorial :: output ()
{
cout << "factorial of " << number << " = " << fact;
}

Armstrong Number

#include <iostream>
#include <conio.h>

using namespace std;

class Armstrong ()
{
private :
int number,temp,carry,cek;

public :
void input ();
void proses ();
void output ();

};

int main ()
{
armstrong a;
a.input ();
a.proses ();
a.output ();

getche ();
return 0;
}

void armstrong :: input ()
{
cout << "input number = ";
cin >> number;
temp = number;
}

void armstrong :: proses ()
{
while (number > 0)
{
carry = number % 10;
cek = cek + (carry*carry*carry);
number = number / 10;
}
}
void armstrong :: output ()
{
if (cek==temp)
{
cout << temp << " is Armstrong number";
}
else
{
cout << temp << " is NOT Armstrong number";
}
}

Bermain dengan shutter speed




Biggest Among N-number

#include <iostream>
using namespace std;

class biggest
{
private :
int jumlah,temp,big;

public :
    void input ()
    {
        cout<<"masukkan jumlah bilangan = "<<endl;
        cin>>jumlah;
    }
    void proses ()
    {
        cout<<"masukkan bilangan  = "<<endl;
        cin>>temp;
        big=temp;
      
        for (int i=2;i<=jumlah;i++)
        {
            cout<<"masukkan bilangan = "<<i<<endl;
            cin>>temp;
            if (big<temp)
            {
                big = temp;
              
            }
        }
    }
    void output ()
    {
        cout<<"biggest number = "<<big<<endl;
    }
};

int main ()
{

biggest b;
b.input ();
b.proses ();
b.output ();

system("PAUSE");
return 0;
}