Pages

Senin, 16 Januari 2012

SEGITIGA BINTANG & ANGKA [TUGAS]

  • SEGITIGA BINTANG & ANGKA
#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void keluar();
void bintang()
{

int a,b,c;
clrscr();
gotoxy(14,14);cout << " Input batas = "; cin >> a;
clrscr();

for (b=1; b<=a; b++){
   for (c=1; c<=b; c++){
   textcolor(c);
   cprintf("*");
   }
   cout << endl;
   }
   keluar();
}

void angka()
{
int a,b,c;
clrscr();
gotoxy(14,14);cout << " Input batas = "; cin >> a;

clrscr();
for (b=1; b<=a; b++){
   for (c=1; c<=b; c++){
   cout<<c;
   }
   cout << endl;
   }
   keluar();
}

void menu()
{
char pil;
clrscr();
textcolor(3);
gotoxy(20,14);cprintf("  JUNED/11051103247 \r \n " );
gotoxy(20,5);cprintf ("  TUGAS DUA  \r \n " );
gotoxy(20,6);cprintf (" -------------------  \r \n " );
gotoxy(20,7);cprintf ("   1. BINTANG         \r \n " );
gotoxy(20,8);cprintf ("   2. ANGKA           \r \n " );
cout<<endl;
gotoxy(20,10);cprintf("  Pilihan : "); cin >> pil;


switch(pil)
{
case '1' : bintang();break;
case '2' : angka();break;
default :
gotoxy(20,3);cprintf(" input anda salah ....!!! ");
getch();
menu();
}
}

void keluar()
{
char x ;
textcolor(12);
cprintf( "\n Kembali ke Menu ...? (Y/N) "); cin >> x;
switch(x)
{
case 'Y' :
case 'y' : menu();break;
case 'N' :
case 'n' :
cout << " thankzzzz";break;
default :
{
cprintf( " input salah ... \r \n");keluar();
}
}
}
void main()
{
menu ();
}
Print Friendly and PDF

Artikel Terkait:

0 komentar:

Posting Komentar

Related Posts Plugin for WordPress, Blogger...