Devilzc0de Forum Follow @devilzc0de
  • Home
  • Hacking
  • Networking
  • Programming
  • O.S
  • Server
  • Tweets
  • Search
  • Member List
  • Calendar
Current time: 05-25-2013, 04:03 AM Hello There, Guest! (Login — Register)
Devilzc0de Forum › Information Technology › Programming › C / C++ v
« Previous 1 ... 6 7 8 9 10 ... 15 Next »

share program c++

Home General Computer Multimedia Business Lounge

Pages (2): 1 2 Next »
Post Reply 
Tweet
Threaded Mode | Linear Mode
share program c++
04-22-2011, 01:27 AM
Post: #1
ndutz.newbie Offline
Asisten Chaer.Newbie
**
Moderators
Posts: 1,295
Joined: Jan 2010
Reputation: 45
share program c++
1. Buat Pyramid Angka 10 baris, seperti gambar di bawah:
1
232
34543
4567654
567898765
67890109876
7890123210987
890123454321098 90123456765432109 0123456789876543210

CODING:
========================================================= #include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
int x, y, z, bil=10;
for( x = 1; x <= bil; x++ )
{
for( z = bil; z >= x; z-- )
cout << ' ';
for( z = x; z < 2*x; z++ )
{
y = z % 10;
cout << y;
}
for( z = 2*(x-1); z >= x; z-- )
{
y = z % 10;
cout << y;
}
cout << endl;
}
getch();
}

2. Tampilkan bilangan Ganjil dan Genap dari 1 sampai 20?
CODING:

1



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130
========================================================= #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int angka;
cout << "Angka Genap dari 1-20" << endl;; for (angka=2; angka<=20; angka+=2)
cout << angka << endl;
cout << "\nAngka Ganjil dari 1-20" << endl;; for (angka=1; angka<=20; angka+=2)
cout << angka << endl;
getch();
}

3. Buat program konversi Celcius ke Fahrenheit?
CODING:
========================================================= #include <conio.h>
#include <stdio.h>
void main()
{
clrscr();
float celcius, fahrenheit; char lagi='Y';
printf("Program konversi celcius ke fahrenheit \n");
do
{
printf("\nNilai celcius : ");
scanf("%f", &celcius);
fahrenheit=1.8*celcius+32;
printf("Nilai fahrenheit : %.2f \n", fahrenheit);
printf("Coba lagi (Y/T) ? ");
scanf("%s", &lagi);
}
while (lagi=='Y' || lagi=='y'); getch();
}

4. Buat program menentukan bilangan prima dari n_awal ke n_akhir?
CODING:
========================================================= #include <conio.h>
#include <iostream.h> #include <math.h>
void prima();
int a,b,c;

void main ()
{

2



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130
clrscr ();
cout<<"Masukkan nilai awal : "; cin>>a;
cout<<"Masukkan nilai akhir: "; cin>>b;
prima ();
getch ();
}
void prima ()
{
cout<<"Bilangan Prima antara "<<a<<"-"<<b<<": "<<endl; for (c=a;c<=b;c++)
{
if ((c==2)||(c==3)||(c==5)||(c==7))
{
cout<<c<<" ";
}
else if ((c%2!=0)&&(c%3!=0)&&(c%5!=0)&&(c%7!=0))
{
cout<<c<<" ";
}
}
}

5. Tampilkan huruf c dengan kolom sebanyak 15 baris sebanyak 10, seperti gambar di bawah?
ccccccccccccccc
ccccccccccccccc
ccccccccccccccc
ccccccccccccccc
ccccccccccccccc
ccccccccccccccc
ccccccccccccccc
ccccccccccccccc
ccccccccccccccc
ccccccccccccccc
ccccccccccccccc

CODING:
========================================================= #include <iostream.h>
#include <conio.h>
main()
{
clrscr();
int x, y;
for (x=1; x<=10; x++)
{
for (y=1; y<=15; y++)
{
cout <<"c";
}
cout<<endl;
}
getch();
}

6. Tampilkan n yang diinput (huruf atau angka) dengan kolom sebanyak n baris sebanyak n?

3



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130
Misal: input: w, kolom: 6, baris: 5
wwwwww
wwwwww
wwwwww
wwwwww
wwwwww
CODING:
========================================================= #include <conio.h>
#include <iostream.h>
int ulang (char hrf, int x, int y); int main()
{
clrscr();
char huruf;
int kolom, baris;

cout << "Menampilkan suatu huruf atau angka sebanyak 'kolom dan
'baris' \n";
cout << "------------------------------------------------------------
- \n \n";

cout << "Berapa kolom ? "; cin >> kolom;
cout << "Berapa baris ? "; cin >> baris;
cout << "Masukkan sebuah huruf atau angka : "; cin >> huruf;
cout << endl;
ulang (huruf, kolom, baris); return 0;
getch();
}

int ulang (char hrf, int x, int y)
{
int i, j;
for (i=0; i<y; i++)
{
for (j=0; j<x; j++) cout << hrf;
cout << endl;
}
getch();
}
7. Buat program menentukan bilangan terbesar dan terkecil dari jumlah data yang diinput?
CODING:
========================================================= #include <conio.h>
#include <stdio.h>
void main()
{
4



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130
clrscr();
int i, n, max, min, bil;
printf ("Program mencari bilangan terbesar dan terkecil \n"); printf("Banyak data : ");
scanf("%d", &n);
printf("Masukkan bilangan : "); scanf("%d", &bil);
max=bil;
min=bil;
for (i=2; i<=n;i++)
{
printf("Masukkan bilangan : "); scanf("%d", &bil);
if (bil>max) max=bil;
if (bil<min) min=bil; }
printf ("Data terbesar %d \n", max);
printf ("Data terkecil %d \n", min);
getch();
}

8. Tampilkan Nilai A, B, C sebagai berikut
Nilai A=a (dari a sampai j) sampai Nilai A=j
Nilai B=5 (perkalian 5 sampai 45) sampai Nilai B=45
Nilai C=2 (perkalian 2 sampai 1024) sampai Nilai C=1024
CODING:
========================================================= #include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
char a;
int b, c;
for (a='a', b=5, c=2; a<='j'; a++, b=b+5, c=c*2)
{
cout<<"Nilai A = "<<a<<endl;
cout<<"Nilai B = "<<b<<endl;
cout<<"Nilai C = "<<c<<endl;
cout<<endl;
}
getch();
}

9. Tampilkan segitiga siku-siku dengan n (input dari 1-20), misal input 4, hasilnya
1
2 4
3 6 9
4 8 12 16
CODING:
========================================================= #include <iostream.h>
#include <conio.h>

5



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130

main()
{
clrscr();
int i, j, k;
cout << "Masukkan jumlah bilangan (1-20) : "; cin >> i;
if (i>0 && i<=20)
for (j=1; j<=i; j++) {
for (k=1; k<=j; k++) {
cout<<k*j<<' ';
}
cout<<'\n';
} else {cout << "Gimana seeh, udah dibilangin dari 1-20..!!!";} getch();
}

10. Tampilkan segitiga dengan n (input dari 1-20), misal input 4, hasilnya
1
2 4
3 6 9
4 8 12 16
3 6 9
2 4
1

CODING:
========================================================= #include <iostream.h>
#include <conio.h>
main()
{
clrscr();
int i, j, k;
cout << "Masukkan jumlah bilangan (1-20) : "; cin >> i;

if (i>=1 && i<=20)
{
for (j=1; j<=i; j++)
{
for (k=1; k<=j; k++)
{
cout<<k*j<<' ';
}
cout<< endl;
}

for (j=i-1; j>=1; j--)
{
for (k=1; k<=j; k++)
{
cout<<k*j<<' ';

6



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130
}
cout<< endl;
}
} else {cout << "Yang diinput harus dari 1-20";}
getch();
}
10 SOAL DARI TINGKAT 3
1. Masukkan kalimat, kemudian tampilkan kalimat tersebut dimulai dari urutan yang paling
belakang (terbalik). Contoh = Hallo -> ollaH
CODING:
========================================================= #include <iostream.h>
#include <conio.h>
#include <string.h>
void balik (char *karakter); void main()
{
clrscr();
char kalimat[100];
cout << "\nMasukkan kata : ";
cin.getline (kalimat, 100);
balik(kalimat);
getch();
}
void balik (char *karakter)
{
int s;
s=strlen(karakter);

cout << "Hasilnya : ";
for (int n=s; n>=0; n--)
{
cout << *(karakter+n);
}
}

2. Buat program jumlah anak ayam diinputkan (n), lalu tampilkan :
Anak ayam turun n, mati satu tinggal n-1
Anak ayam turun 0, mati satu tinggal induknya
CODING:
========================================================= #include <iostream.h>
#include <conio.h>
main()
{
7



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130
clrscr();
int x, y;
cout << "Masukkan jumlah anak ayam : "; cin >> x;

for (y=x; y>=1; y--)
{
if (y==1) {
cout << "Anak ayam turun " << y << ", mati satu tinggal induknya " <<endl;}
else {

cout << "Anak ayam turun " <<endl;}
}
getch();
}

<< y << ", mati satu tinggal " << y-1


3. Tampilkan bilangan Faktorial dari n! dan hasilnya => 3! = 3 x 2 x 1 = 6
CODING:
========================================================= #include <iostream.h>
#include <conio.h>
main() {
clrscr();
int C, BIL;
long faktorial = 1;
cout << "Masukkan bilangan yang akan dihitung : "; cin >> BIL;
C=BIL;
cout << C << "! = ";
while (C >= 1) {
faktorial *= C;
if (C != 1) {
cout << C <<" x "; } else {
cout << C <<" = ";
}
C--;
}
cout << faktorial;
getch();
}

4. Buat program untuk menampilkan tahun kabisat dari n_awal hingga n_akhir yang angka
terakhirnya 6
CODING:
========================================================= #include <iostream.h>
#include <conio.h>

8



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130
int main()
{
clrscr();
int a, b, tahun; float i=0;

cout << "Masukkan tahun awal : ";
cin >> a;
cout << "Masukkan tahun akhir : "; cin >> b;
cout << "Tahun kabisat yang berakhiran 6 adalah : \n"; for (tahun=a; tahun<=b; tahun++) {
if (tahun%4==0 && ((tahun+4)%20==i) && tahun%100!=0) { cout << tahun << ' ';
} else {
cout << "";
}
}
getch();
}

5. Program menampilkan bilangan yang habis dibagi 6 dari n_awal hingga n_akhir
CODING:
========================================================= #include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
int a, b, bil;

cout << "Masukkan bilangan awal : ";
cin >> a;
cout << "Masukkan bilangan akhir : "; cin >> b;
cout << "\nBilangan yang habis dibagi 6 adalah : \n"; for (bil=a; bil<=b; bil++) {
if (bil%6==0) {
cout << bil << ' '; } else {
cout << "";
}
}
getch();
}

6. Animasi angka 0 berjalan dari pojok kiri atas hingga pojok kanan dalam satu baris
CODING:
========================================================= #include <iostream.h>
#include <conio.h>
#include <dos.h>

9



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130

int main()
{
clrscr();
int j;
for (j=1; j<=80; j++) { cout << "0";
delay(100);
}
cout<<'\n';
getch();
}

Tampilkan formasi bintang berikut :
7. *
**
*
**

CODING:
========================================================= #include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
int x, y, z, bil=3;

for( x = bil; x >= 1; x-- )
{
for( z = x; z <= bil; z++ )
cout << '*';
cout << endl;
}
for( x = 1; x <= bil; x++ )
{
for( z = bil; z >= x; z-- )
cout << ' ';
for( z = x; z < 2*x; z++ )
{
y = z % 10;
cout << '*';
}
cout << endl;
}
getch();
}






10



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130
Tampilkan formasi bintang berikut :
8. * * * **
*
**
*
CODING:
========================================================= #include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
int x, y, z, bil=10;

for( x = bil; x >= 1; x-- )
{
for( z = x; z <= bil; z++ )
cout << ' ';
for( z = 2*x; z > x; z-- )
{
y = z % 10;
cout << "*";
}

for( z = x; z <= 2*(x-1); z++ )
{
y = z % 10;
cout << "*";
}
cout << endl;
}
getch();
}

Tampilkan formasi bintang berikut :
9. * *
** **
* *
** **
**
CODING:
========================================================= #include <iostream.h>
#include <conio.h>
int main()
{
clrscr();

11



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130
int x, y, z, bil=10;

for( x = bil; x >= 1; x-- )
{
for( z = x; z <= bil; z++ )
cout << '*';
for( z = 2*x; z > x; z-- )
{
y = z % 10;
cout << ' ';
}
for( z = x; z <= 2*(x-1); z++ )
{
y = z % 10;
cout << ' ';
}
for( z = bil; z >= x; z-- )
cout << '*';
cout << endl;
}
getch();
}

Tampilkan formasi bintang berikut :
10.
0 * * *
00 * * * * *
00 0 * * * *
00 00 * * *
00 000 * *
00 0000 *
CODING:
========================================================= #include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
int x, y, z, bil=10;
for( x = bil; x >= 1; x-- )
{
for( z = x; z <= bil; z++ )
cout << '0';
for( z = 2*x; z > x; z-- )
{
y = z % 10;
cout << '*';
}
cout << endl;
}
getch();
}

12



TUGAS 1 TI 9

IMAM CIPTARJO - 6307130

SOAL DARI BAPAK RUDI FIRMAN
1. Tampilkan deretan dari 1-100, tentukan angka yang mempunyai nilai 9?
CODING:
========================================================= #include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
clrscr();

for(int x=0; x<=100; x++)
{
cout << x << ",";
}
cout << "\n" << endl;

for(int y=1; y<=80;)
{
if (y==0)
{
y+=1;
}
else if (y==1)
{
y+=8;
}
else if (y>=1 && y<=100)
{
y+=10;
}
cout << "\n Angka 9 diantara 1-100 : " << y;
}
for (y=90; y<=99; y++)
cout << "\n Angka 9 diantara 1-100 : " << y;
getch();
}




Find all posts by this user
Quote this message in a reply
04-22-2011, 01:45 AM
Post: #2
Matmund Newbie Away
Devilzc0deR Sejati
****
Global Moderators
Posts: 856
Joined: Mar 2010
Reputation: 36
RE: share program c++
ebook tutorial lengkap'a ane minta om
Visit this user's website Find all posts by this user
Quote this message in a reply
04-22-2011, 01:53 AM
Post: #3
ndutz.newbie Offline
Asisten Chaer.Newbie
**
Moderators
Posts: 1,295
Joined: Jan 2010
Reputation: 45
RE: share program c++
(04-22-2011 01:45 AM)matmund Wrote:  ebook tutorial lengkap'a ane minta om

http://www.ziddu.com/download/14692174/soal.pdf.html
Find all posts by this user
Quote this message in a reply
04-22-2011, 04:38 AM
Post: #4
tian hv Offline
./Sampah Masyarakat
Posts: 486
Joined: Mar 2010
Reputation: 18
RE: share program c++
mantap om ndutz....

mata kuliah ane ne...
thanks banget om..
asik
Visit this user's website Find all posts by this user
Quote this message in a reply
04-22-2011, 10:08 AM
Post: #5
ndutz.newbie Offline
Asisten Chaer.Newbie
**
Moderators
Posts: 1,295
Joined: Jan 2010
Reputation: 45
RE: share program c++
(04-22-2011 04:38 AM)tian hv Wrote:  mantap om ndutz....

mata kuliah ane ne...
thanks banget om..
asik
sama sama om asik
Find all posts by this user
Quote this message in a reply
04-22-2011, 12:49 PM
Post: #6
justlearn Offline
./Devilz Advisor
Posts: 527
Joined: Aug 2010
Reputation: 31
RE: share program c++
(04-22-2011 10:08 AM)ndutz.newbie Wrote:  
(04-22-2011 04:38 AM)tian hv Wrote:  mantap om ndutz....

mata kuliah ane ne...
thanks banget om..
asik
sama sama om asik

wakakaaka....gara gara masuk http://forum.sekolahdigital.com/forumdisplay.php?fid=7

jadi jago tuuhhh ngakak ngakak dugem dugem bangga
Visit this user's website Find all posts by this user
Quote this message in a reply
04-24-2011, 12:08 AM
Post: #7
ndutz.newbie Offline
Asisten Chaer.Newbie
**
Moderators
Posts: 1,295
Joined: Jan 2010
Reputation: 45
RE: share program c++
(04-22-2011 12:49 PM)justlearn Wrote:  
(04-22-2011 10:08 AM)ndutz.newbie Wrote:  
(04-22-2011 04:38 AM)tian hv Wrote:  mantap om ndutz....

mata kuliah ane ne...
thanks banget om..
asik
sama sama om asik

wakakaaka....gara gara masuk http://forum.sekolahdigital.com/forumdisplay.php?fid=7

jadi jago tuuhhh ngakak ngakak dugem dugem bangga

hei hei udah di benerin blm?ane masih di banned tuh suram
Find all posts by this user
Quote this message in a reply
04-24-2011, 12:56 PM
Post: #8
bogenk Offline
./Devilz Commander
Posts: 267
Joined: Apr 2011
Reputation: 2
RE: share program c++
wahahh...muantep om..

om C ni..

salam knal om, ane aan.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-24-2011, 11:25 PM
Post: #9
ndutz.newbie Offline
Asisten Chaer.Newbie
**
Moderators
Posts: 1,295
Joined: Jan 2010
Reputation: 45
RE: share program c++
(04-24-2011 12:56 PM)bogenk Wrote:  wahahh...muantep om..

om C ni..

salam knal om, ane aan.

sama sama lam kenal juga omsantaismangat
Find all posts by this user
Quote this message in a reply
01-23-2012, 06:22 PM
Post: #10
eliechijuljul Offline
./Devilz 1st Cadet
Posts: 1
Joined: Dec 2011
Reputation: 0
RE: share program c++
om ndutz.... om ndutz...... klo mnampilkan deret Fibonacci gmn...??? ketawa
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Pages (2): 1 2 Next »
Post Reply 


Topic Tools
Topic Link :
BBCode :
HTML Code :
View a Printable Version Send Thread to a Friend Subscribe to this thread
Submit Google Submit Face book Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Ask] Buat Program the_critical 13 332 02-05-2013 08:17 PM
Last Post: the_critical
  [Tutor] Send Mail Gmail & Yahoo dengan Program C# kadoel 8 240 12-17-2012 09:27 AM
Last Post: kadoel
  [Tutor] Program Send Mail dengan C# kadoel 18 373 12-15-2012 07:20 PM
Last Post: hazel
Thumbs Up [Tutor] Program Urutkan Data dengan metode insertion sort chentiz 4 151 12-10-2012 10:18 PM
Last Post: chentiz
  [Tutor] Program Penghitung Jarak Tempuh dan Konsumsi BBM (galon/mil) hitheir 9 252 12-02-2012 09:36 PM
Last Post: bari
  [ASK] program stack (need fast) chaosloki 10 252 11-14-2012 11:36 PM
Last Post: momoi
  Program pertama c++ ane(hanya share) Faizal97 4 152 11-06-2012 09:53 PM
Last Post: Faizal97
  [Ask] Penjelasan Program Ini Gimana Ya?? littleshadow 6 338 10-28-2012 05:40 PM
Last Post: momoi
  [Ask] Mohon Pencerahannya! PROGRAM JAM (BAHASA C BUKAN C++) ezurasan 7 451 07-16-2012 07:13 PM
Last Post: syn_attack
  Program Pertama Ane! Semat_Semut 21 653 07-13-2012 05:49 PM
Last Post: !and

Users Browsing
1 Guest(s)

  • Contact Us
  • devilzc0de
  • Return to Top
  • Mobile Version
  • RSS Syndication
  • Help
Current time: 05-25-2013, 04:03 AM Powered By MyBB, © 2002-2013 MyBB Group. Theme created by Justin S. | Mixed By Chaer.Newbie | Fixed By Aditya

USING THIS SITE INDICATES THAT YOU HAVE READ AND ACCEPT OUR TERMS. IF YOU DO NOT ACCEPT THESE TERMS, YOU ARE NOT AUTHORIZED TO USE THIS SITE