Pages

Banner 468 x 60px

 

Saturday 29 December 2012

AL-Goritma Pemula

0 comments
        LATIHAN ALGOTITMA



yang suka akan mata kuliah Algoritma mangga di cek

#include<stdio.h>
#include<conio.h>
main()
{
//deklarasi variabel
int P,L,LS;
 P=8;
 L=2;
 LS=P*L;

clrscr();

printf("NILAI\t P=%d",P);
printf("\nNILAI\t L=%d",L);
printf("\nNILAI\t LS=%d",LS);
getche();
}

    HASIL

NILAI    P=8
NILAI    L=2
NILAI    LS=16

================================================

#include<stdio.h>
#include<conio.h>
main()
{

int ANDI=8, RIA=9, NANA=6, LINA=3;
float YADI=6.75, TEDI=8.81, HENI=5.43, RANI=7.75;

clrscr();

printf("ANDI=%d",ANDI);printf("\tYADI=%2.2f",YADI);
printf("\nRIA=%d",RIA);printf("\tTEDI=%2.2f",TEDI);
printf("\nNANA=%d",NANA);printf("\tHENI=%2.2f",HENI);
printf("\nLINA=%d",LINA);printf("\tRANI=%2.2f",RANI);

getche();
}

    HASIL

ANDI=8    YADI=6.75
RIA=9    TEDI=8.81
NANA=6    HENI=5.43
LINA=3    RANI=7.75

========================================================

#include<stdio.h>
#include<conio.h>
main()
{
//deklarasi variabel
int a,b,c;
 a=7;
 b=8;
 c=a*b;

clrscr();

printf("NILAI\t A=%d",a);
printf("\nNILAI\t B=%d",b);
printf("\nNILAI\t C=%d",c);
getche();
}

    Hasil

NIALI    A=7
NIALI    B=8
NIALI    C=56

==============================================================

# include <stdio.h>
# include <conio.h>
# include <iostream.h>
# include <iomanip.h>
main ()
{
int A=100.000,B=150.000,C=200.000;
clrscr();
cout<<"Daftar Gaji Pegawai"<<"\n\n";
cout<<"gol A            gol B            gol C"<<endl;
cout<<"- - - - - - - - - - - - - - - - - - - - - - - - "<<"\n";
cout<<A<<"            ";
cout<<B<<"            ";
cout<<C<<endl;
getche();
}

    Hasil

Daftar Gaji Pegawai

gol A            gol B            gol C
- - - - - - - -- - - - - - - - - - - - -- - - - - -
100            150            200

====================================================================

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

main ()
{
    float a=7.50,    b=243.21, c=3.21;
   float d=17.50,    e=47.41, f=3.1;
   clrscr ();

   printf ("%8.2f\t%8.2f\t%8.2f\t",a,b,c);
   printf ("\n %8.2f\t%8.2f\t%8.2f\t",d,e,f);
   getche();
}

        Hasil

    7.50    243.21    3.21
    17.50    47.41    3.10

===============================================================

# include <stdio.h>
# include <conio.h>
# include <iostream.h>
# include <iomanip.h>
main ()
{
int a=75,b=56;
clrscr();
cout<<"Pengunan ios::left dan ios::right\n\n";
cout<<"Rata sebelah kiri=";
cout<<setiosflags(ios::left)<<setw(10)<<a;
cout<<setiosflags(ios::left)<<setw(10)<<b;
cout<<endl;
cout<<"Rata sebelah kanan=";
cout<<setiosflags(ios::left)<<setw(10)<<a;
cout<<setiosflags(ios::left)<<setw(10)<<b;
getche();
}

    Hasil
Pengunan ios::left dan ios::right

Rata sebelah kiri=75    56
Rata ebelah kanan=75    56

=============================================================

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

main ()
{

float a = 7.50, b = 243.21, c = 3.21;
float d = 17.50, e = 47.41, f = 3.1;
clrscr ();
printf("%8.2f\t%8.2f\t%8.2f\t",a,b,c);
printf ("\n %8.2f\t%8.2f\t%8.2f\t",d,e,f);
getche ();
}

    Hasil

7.50    243.21        3.21
17.50    47.41        3.10

====================================================

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
main ()
{
//Deklarasi Variabel
int a,b,c;
clrscr ();
a=20;
b=5;
c=a+b;
cout <<"Nilai c="<<c;
getche ();
}

    Hasil

(Nilai Luas=25)

==========================================================

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
main ()
{
//Deklarasi Variabel
int p,l,ls;
clrscr ();
p=20;
l=5;
ls=p+l;
printf ("Nilai luas =%d",ls,p,l);
getche ();
}

Hasil    (Nilai Luas=25)

====================================================

# include <stdio.h>
# include <conio.h>
# include <iostream.h>
# include <iomanip.h>
main ()
{
int a;
clrscr();
cout<<"Pengunan manipulator setfill()"<<"\n\n";
cout<<"======================================"<<"\n";
for(a=1;a<=15;a++)
{
cout<<setfill('=');
cout<<setw(a)<<a<<endl;
}
cout<<"======================================="<<"\n";
getche();
}

    Hasil

Pengunan manipulator setfill<>
================================================
1
=2
==3
===4
====5
=====6
======7
=======8
========8
=========9
==========10
===========11
============12
=============13
==============14
================15
===============================================

=========================================================

0 comments:

Post a Comment