Contoh (2) Fungsi dalam C++ (input bukan didalam sistem)

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

float fungsi (float x);
float x;
void main()
{

clrscr();

cout<<"MENCARI NILAI FUNGSI f(x)=2x-3x+1"<<endl;
cout<<"Nilai x: ";
cin>> x;
cout<<"Nilai fungsi dari x adalah: " <<fungsi(x)<<endl;
getch();
}
float fungsi (float x)
{
float fungsi;
fungsi=(2*x)-(3*x)+1;
return fungsi ;
}

lalu di run
input yang bukan langsung dimasukan kedalam sistem misal x=25


Komentar

Postingan Populer