Kamis, 24 Maret 2016

KASUS-KASUS MINGGU KE4


DEV C++
source code :
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int main(int argc, char** argv) {
    int i;
    for (i=1;i<=4;i++){
     cout<<i<<", ";
    }
return 0;
}


output :
RAPTOR




DEV C++
source code :
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int main(int argc, char** argv) {
 int i;
   for(int i=0;i<=10;i++){
   if(i%2==1)
   cout<<i<<endl;
            }
return 0;
}

output :


RAPTOR

DEV C++
source code :
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std; 
int main(int argc, char** argv) {
int a, n, jumlah=0 , b;
float rata;
cout<<"\t\tProgram Mencari Rata-rata dari n bilangan positif"<<endl<<endl;
cout<<"Masukan Banyaknya Data : "; cin>>n;
for (a=1;a<=n;a++){
    cout<<"Data ke "<<a<<" : "; cin>>b;
    jumlah +=b;
}
rata=(float)jumlah/n;
cout<<"Rata-rata = "<<rata;
return 0;
}

output :

RAPTOR

DEV C++
source code :
#include <iostream>
#include <string>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std; 
int main(int argc, char** argv) {
   float x,hasil;
   int i, y;
   hasil = 1;
   cout << "Masukkan angka yang ingin dipangkatkan = ";
   cin >> x;
   cout << "Masukkan pangkat = ";
   cin >> y;
   cout << endl;
   if (y>=0){
      i =1;
      while (!(i>y)){
         hasil =hasil*x;
         i =i+1;
      }
   }
   else{
      i =0;
      while (!(i<=y)){
         hasil =hasil*(1/x);
         i =i-1;
      }
   }
   cout << "=> " << x << " pangkat " << y << " adalah " << hasil << endl;
return 0;
}

outputnya :

RAPTOR

Tidak ada komentar:

Posting Komentar