Sunday, October 9, 2011

Latihan

Latihan fungsi cout

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

main()
{
cout<<"Selamat datang di Blog Catatan Imam \n";
getch();
}










Latihan integer

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
 printf("input nilai a=");scanf("%d",&a);
 printf("input nilai b=");scanf("%d",&b);
c=a+b;
printf("output nilai=%d",c);
clrscr();
 printf("HITUNG NILAI\n");
 printf("NILAIA;%D\n",a);
 printf("NILAIB;%D\n",b);
 printf("________________\n");
 printf("NILAIC;%d\n",c);
getch();
}



















_____________________________________

#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main( )
{
int x,y, a=0, b=0, c=0, d=0;
clrscr( );
cout<<"Masukan Nilai A : "; cin>>x;
cout<<"Masukan Nilai B : "; cin>>y;
a=x+y; c = x% y;
b=x-y; d = x * y;
printf(“Hasil Dari A= X + Y= %i \n” , a);
printf(“Hasil Dari B=X - Y= %i \n”,b)
cout<<"Hasil dari C = X % Y ="<<c<<endl;
cout<<"Hasil dari D = X * Y ="<<d<<endl;
getch( );
}












_____________________________________

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
main()
{
int jrk,tot;
char np[20],ns[25];
cout<<"APLIKASI TAXI";
cout<<"==============================================="<<endl;
cout<<"Masukan Nama Supir          =";gets(ns);
cout<<"Masukan Nama Penumang       =";gets(np);
cout<<"Masukan Jarak Tempuh        =";cin>>jrk;
tot=(jrk-1)*20000+50000;
clrscr();
cout<<"Penumpang dengan nama"<<np<<ends;
cout<<"menaiki taxi dengan jarak tempuh"<<jrk<<"Km."<<endl;
cout<<"Uang yang harus dibayarkan sebesar Rp. "<<tot<<" kepada "<<ns<<".";
getch();
}


 
Comments
0 Comments

0 comments:

Post a Comment