skip to main |
skip to sidebar
#include <conio.h>
#include <iostream.h>
#pragma argsused
int main()
{
int i,x,f,k,hasil;
cout<<"FAKTORIAL BILANGAN"<<endl;
cout<<"------------------"<<endl;
cout<<endl;
cout<<"Masukkan jumlah faktorial : "; cin>>x;
cout<<endl;
for(i=1;i<=x-1;i++)
{
cout<<i<<"! : ";
hasil=1;
for(f=1;f<=i;f++)
{
k=f;
hasil=hasil*k;
}
cout<<hasil;
cout<<endl;
}
cout<<"--------------------------"<<endl;
cout<<i<<"! : ";
for(i=1;i<=x;i++)
{
cout<<i<<" * ";
}
cout<<endl;
for(i=1;i<=x;i++)
{
hasil=1;
for(f=1;f<=i;f++)
{
k=f;
hasil=hasil*k;
}
}
i=x;
cout<<i<<"! : "<<hasil;
getch();
}
#include <conio.h>
#include <iostream.h>
#pragma argsused
int main()
{
int n0,n1,n2,i,bil;
cout<<"DERET BILANGAN FIBONACCI"<<endl;
cout<<"------------------------"<<endl;
cout<<endl;
cout<<"Masukkan batas bilangan : ";
cin>>bil;
cout<<endl;
cout<<"Deret Bilangan : ";
for(i=1;i<=bil;i++)
{
cout<<i<<" ";
}
cout<<endl;
cout<<"Deret Fibonacci : ";
n0=0;
n1=1;
for(i=1;i<=bil;i++)
{
n2=n0+n1;
cout<<n2<<" ";
n0=n1;
n1=n2;
}
getch();
}
#pragma argsused
#include<iostream.h>
#include<conio.h>
int main()
{
int nilai[20];
int i,x,j,k,temp;
cout<<"Mengurutkan Data Nilai"<<endl;
cout<<"======================"<<endl;
cout<<endl;
cout<<"Masukkan Banyak Input = ";cin>>x;
cout<<"------------------------"<<endl;
for(i=1;i<=x;i++)
{
cout<<"Nilai Ke-"<<i<<" : "; cin>>nilai[i];
}
cout<<endl;
cout<<"----------------------------"<<endl;
cout<<"Input sebelum diurutkan : "<<endl;
for(i=1;i<=x;i++)
{
cout<<nilai[i]<<" ";
}
cout<<endl;
cout<<endl;
for(j=1;j<=x;j++)
{
for(k=j+1;k<=x;k++)
{
if(nilai[j]>nilai[k])
{
temp=nilai[j];
nilai[j]=nilai[k];
nilai[k]=temp;
}
}
}
cout<<"Input setelah diurutkan : "<<endl;
for(i=1;i<=x;i++)
{
cout<<nilai[i]<<" ";
}
getch();
}