Coding Visual 6.0

 1. Pyramid Angka 10 baris……………………………….

#include"iostream.h"
#include"conio.h"
void main() 
{
           
                        int x,y,z,bil=10;
                        for(x=1;x<=bil;x++)
            {
                        for(z=1;z<bil-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();
}















  1. Konversi Celcius ke Fahrenheit!

#include"iostream.h"
#include"conio.h"
void main()
{
     
      float celcius,fahrenheit;
      char lagi='Y';
      cout<<"Program Konversi Celcius Ke Fahrenheit"<<endl;
      do{
      cout<<"\nNilai Celcius      : ";
      cin>>celcius;
      fahrenheit=1.8*celcius+32;
      cout<<"Nilai Fahrenheit   : "<<fahrenheit<<endl;
      cout<<"Coba Lagi (Y/T)? ";
      cin>>lagi;
      }while(lagi=='Y' || lagi =='y');
      getch();
}



























3.     Bilangan prima dari n_awal ke n_akhir!

#include”iostream.h”      
#include”conio.h”
void prima();
int a,b,c;
void main()
{                 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<<” “;
}
                  }
}




















0 komentar:

Posting Komentar

 

Serba Ada Blog Copyright © 2011-2012 | Powered by Blogger