Recent Videos

Blogger TemplatesMy Blogger TricksAll Blogger Tricks

Senin, 13 Januari 2014

PROGRAM PERULANGAN




·         PROGRAM MENCARI HURUF VOKAL

#include <iostream>
#include <string.h>
#include <cstdlib>

using namespace std;

int main ()
{
                cout<<"\tPROGRAM MENCARI HURUF VOKAL\n\n";
                cout<<"\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n";
charkalimat[50];
                cout<<"Char = 50\n";
cout<<"*** TuliskanKalimatAnda:\n";
cin.getline (kalimat,50);
inti;
intvokal = 0;
for(i=0; i<strlen(kalimat); i++)
{if (kalimat[i] == 'a' || kalimat[i] == 'A' ||
kalimat[i] == 'i' || kalimat[i] == 'I' ||
kalimat[i] == 'u' || kalimat[i] == 'U' ||
kalimat[i] == 'e' || kalimat[i] == 'E' ||
kalimat[i] == 'o' || kalimat[i] == 'U'  ){
vokal++;                                                                              
}
}
cout<<"\n~~~>jumlahvokal=";
cout<<vokal<<endl;
}
                                                               
//exmpl :
//char kalimat[] = "saya ";
//isikalimat[0] = 's'
//isikalimat[1] = 'a'
//isikalimat[2] = 'y'
//strlenfungsibuatmendapatkanpanjang string, jikaditemukan array berupaa,i,u,e,omakavariabelvokal +1.




·         PROGRAM PERULANGAN SEGITIGA
#include<iostream>
#include <stdlib.h>
using namespace std;
int main()
{
        chartombol;
        intmenu,a,b,c,v,x,y,z;
        menu:
        system ("cls");  
        cout<<"\t\t\t\t KELOMPOK 11\n";
        cout<<"\t\t\t PROGRAM PERULANGAN SEGITIGA\n ";
        cout<<"\t\t===========================================\n ";
        cout<<"\t\t===========================================\n"<<endl;
        cout<<"1.SEGITIGA RATA KIRI\n";
        cout<<"2.SEGITIGA RATA KANAN\n";
        cout<<"3.KOMBINASI SEGITIGA RATA KIRI\n";
        cout<<"4.KOMBINASI SEGITIGA RATA KIRI DAN KANAN\n";
        cout<<"5.SEGITIGA PIRAMID\n";
        cout<<"\nSilahkanMasukkanPerulangan SEGITIGA Yang AndaInginkan (1-5) : ";cin>>menu;
        switch(menu)
       
{
        case 1:
                        system ("cls");
                        cout<<"SEGITIGA RATA KIRI\n\n";
                        cout<<"MasukkanJumlahBaris=";
                        cin>>z;cout<<endl;
                       
                        for(int y=0;y<=z;y++)
                        {
                        for(x=1;x<=y;x++)
                       
                        cout<<"*";
                        cout<<endl;
                        }
                        cout<<"\n";
                        cout<<"\n===========================================\n ";
                        break;
                       
        case 2:
                        system ("cls");
                        cout<<"SEGITIGA RATA KANAN\n\n";
                        cout<<"MasukkanAngka : ";cin>>a;
                        cout<<"\n";
       
                        for(b=0;b<a;b++)
                        {
                        for(c=0;c<a-b;c++)
                        cout<<" ";
                       
                        for(c=0;c<=b;c++)
                        cout<<"*";
                        cout<<"\n";
                        }
                        cout<<"\n";
                        cout<<"\n===========================================\n ";
                        break;
                       
        case 3:
                        system ("cls");
                        cout<<"KOMBINASI SEGITIGA RATA KIRI\n\n";
        cout<<"MasukkanAngka : ";cin>>a;
                        cout<<"\n";
       
                        for(b=0;b<a;b++)
                        {
                        for(c=0;c<a-b;c++)
                        cout<<"*";
                        cout<<"\n";
                        }
                        for(b=0;b<a;b++)
                        {
                        for(c=0;c<=b;c++)
                        cout<<"*";
                        cout<<"\n";
                        }
       
        cout<<"\n";
                        cout<<"\n===========================================\n ";
                        break;
                       
        case 4:
                        system ("cls");
                        cout<<"KOMBINASI SEGITIGA RATA KIRI DAN KANAN\n\n";
                        cout<<"MasukkanJumlahBaris=";
                        cin>>z;cout<<endl;
                        for(int y=1;y<=z;y++)
                        {
                       
                        for(x=1;x<=y;x++)
                       
                        {cout<<"*";}
                       
                        for(v=z; v>=x; v--)
                        {cout<<"  ";}

                        for(v=x;v<x;v++)
       
                        { cout<<"*";}
       
                        for(v=2*(x-1);v>=x; v--)
       
                        { cout<<"*";}
       
                        cout<<"\n";
                        }
                       
                        cout<<"\n";
                        cout<<"\n===========================================\n ";
       
                        break;
                       
        case 5:
                        system ("cls");
                        cout<<"SEGITIGA PIRAMID\n\n";
                        cout<<"MasukkanTinggiPiramid = ";cin>>a;

                        for(x=1; x<=a; x++)
                        {
                                        for(z=a; z>=x; z--)
                                        cout<<" ";

                                        for(z=1;z<x+x;z++)
                                        {
                                                        cout<<"*";
                                        }

                                        cout<<"\n";
                        }
                       
                        cout<<"\n";
                        cout<<"\n===========================================\n ";
       
                        break;
       
                                                                                       
}
                                                        cout<< "Apakahmaumengulangi (Y/T)?";cin>>tombol;
                                                       
                                                        cout<<endl;
                                                        if (tombol == 'Y' || tombol == 'y'){goto menu;}
                                                        else
                                                        {
                                                        cout<< "Selesai";
                                                        }
       
                       
}

0 komentar:

Posting Komentar

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews