Menghitung nilai Faktorial

Post on 21-Dec-2015

217 views 1 download

description

tugas polinema

Transcript of Menghitung nilai Faktorial

Menghitung nilai Faktorial

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

int main(){int bil, n;int hasil;

cout<<"Menghitung nilai Faktorial" << endl ;cout<<"\Masukan angka = ";cin>> n; hasil=1;for(bil=n; bil>=1;bil--){hasil=hasil*bil;}cout<<"Hasil Faktorial= "<<hasil<<"\n";getch();}

Menghitung Jumlah Data#include<iostream>#include<conio.h>

int main(){int bil, n;int hasil;

cout<<"Menghitung JUMLAH " << endl ;cout<<"\Masukan angka terakhir dijumlah = ";cin>> n;

hasil=0;for(bil=n; bil>=1;bil--){hasil=hasil+bil;}cout<<"Hasil jumlah= "<<hasil<<"\n";getch();}

Menampilkan Gambar

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

void main (){int a, b, c;

cout << "BANYAKNYA BINTANG : " ;cin >> a;cout << "\n";for (b = 1; b <= a; b++){for (c = 1; c <= b; c++)cout << "*" ;cout << "\n";}

getch () ;

}

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

main() {int a,b,c;cout<<"banyak bintang :";cin>>b;for (a=1; a<=b; a++ ) {for(c=1;c<=b;c++) cout<<"*";cout << "\n";}getch();}