For naik
===============================
#include <cstdlib>
#include <iostream>
#include <conio.h>
using namespace std;
class angka{
public:
angka(){nilai;}
void interatif(int nilai);
private:
int i, nilai;
};
void angka::interatif(int nilai)
{
int i=1;
cout<<"Masukan Nilai : ";
cin>>nilai;
{
for(int i=1; i<=nilai; i++)
cout << i << endl;
}
}
int main(int argc, char *argv[])
{
{
angka x;
cout<<"\nMencetak Bilangan\n"<<endl;
x.interatif(0);
}
system("PAUSE");
getch;;
}
=================================
=================================
#include <cstdlib>
#include <iostream>
#include <conio.h>
using namespace std;
class angka{
public:
angka(){nilai;}
void interatif(int nilai);
private:
int i, nilai;
};
void angka::interatif(int nilai)
{
int i=9;
cout<<"Masukan Nilai : ";
cin>>nilai;
{ for(int i=9; i>=nilai; i--)
cout << i << endl;
}
}
int main(int argc, char *argv[])
{
{
angka x;
cout<<"\nMencetak Bilangan\n"<<endl;
x.interatif(0);
}
system("PAUSE");
getch;;
}
================================
While naik
================================
#include <cstdlib>
#include <iostream>
using namespace std;
class naik{
private:
int a;
public:
naik();
void proses();
};
naik::naik(){
cout<<" menghitung 1 sampai dengan 9\n\n";
}
void naik::proses(){
a=1;
while (a<=9){
cout<<a<<endl<<endl;
a++;
}
}
int main(int argc, char *argv[])
{ naik x;
x.proses();
system("PAUSE");
return 0;
}
================================
While turun
================================
#include <cstdlib>
#include <iostream>
using namespace std;
class turun{
private:
int a;
public:
turun();
void proses();
};
turun::turun(){
cout<<" menghitung 1 sampai dengan 9\n\n";
}
void turun::proses(){
a=9;
while (a>=1){
cout<<a<<endl<<endl;
a--;
}
}
int main(int argc, char *argv[])
{ turun x;
x.proses();
system("PAUSE");
return 0;
}
=================================
Repeat Until naik
=================================
#include <cstdlib>
#include <iostream>
using namespace std;
class naik{
private:
int i;
public:
naik();
void proses();
};
naik::naik(){
cout<<" menghitung 1 sampai dengan 9\n\n";
}
void naik::proses(){
int i=1;
do{
cout<<i<<endl<<endl;
i++;
}
while (i<=9);
}
int main(int argc, char *argv[])
{ naik x;
x.proses();
system("PAUSE");
return 0;
}
=================================
Repeat Until turun
=================================
#include <cstdlib>
#include <iostream>
using namespace std;
class turun{
private:
int i;
public:
turun();
void proses();
};
turun::turun(){
cout<<" menghitung 1 sampai dengan 9\n\n";
}
void turun::proses(){
int i=9;
do{
cout<<i<<endl<<endl;
i--;
}
while (i>=1);
}
int main(int argc, char *argv[])
{ turun x;
x.proses();
system("PAUSE");
return 0;
}
Untuk SS while sama Repeat Until di pending dulu.. sekian..
0 komentar:
Posting Komentar