Home > C++ > Perbedaan Penggunaan “iostream.h” dan “stdio.h”

Perbedaan Penggunaan “iostream.h” dan “stdio.h”

Pada contoh aplikasi dibawah ini kita akan mencoba mengetahui perbedaan kode pada penggunaan kedua fungsi di atas.

// Aplikasi <iostream.h>
#include <iostream.h>
#include <conio.h>
#include <math.h>

double scale(double x, int n);
int main(void)
{
double num_1;
int num_2;
cout<<“masukkan bilangan real = “;
cin>>num_1;
cout<<“masukkan bilangan integer = “;
cin>>num_2;
cout<<“Hasil pemanggilan fungsi scale adalah = “<< scale(num_1, num_2);
getch();
return(0);
}

double scale(double x, int n) {
double scale_factor;
scale_factor=pow(10,n);
return(x*scale_factor) ;
}

// Aplikasi <stdio.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
double scale(double x, int n);
int main(void)

{
double num_1;
int num_2;
printf(“masukkan bilangan real = “);
scanf(“%lf”, &num_1);
printf(“masukkan bilangan integer = “);
scanf(“%d”, &num_2);
printf(“Hasil pemanggilan fungsi scale adalah %f\n = “, scale(num_1, num_2));
getch();
return(0);
}

double scale(double x, int n) {
double scale_factor;
scale_factor=pow(10,n);
return(x*scale_factor) ;
}

Selamat Mencoba

Categories: C++
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: