Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
38 views3 pages

#Sabtu Algo 6 Rahmatrinaldi 121300032

This document contains C# code that defines a class called cl_masuk with methods for inputting values, processing exponents, and outputting results. The main method instantiates an object of cl_masuk and calls its input method.

Uploaded by

duceboy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views3 pages

#Sabtu Algo 6 Rahmatrinaldi 121300032

This document contains C# code that defines a class called cl_masuk with methods for inputting values, processing exponents, and outputting results. The main method instantiates an object of cl_masuk and calls its input method.

Uploaded by

duceboy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

using System;

namespace Consolerekursi
{
class cl_masuk{
private int bil = 0;
private int pangkat = 0;
private int hasil = 0;
public void input(){
Console.Write("Masukkan nilai =");
bil=Convert.ToInt32(Console.ReadLine());
Console.Write("Pangkat :");
pangkat=Convert.ToInt32(Console.ReadLine());
hasil= Proses(bil,pangkat);
Hasil(hasil);
}
public int Proses(int a, int b){
if (b==0){
return 1;
}
else {
return a*Proses (a, b-1);
}
}
public void Hasil(int hasil1){
Console.WriteLine("hasilnya =" + hasil1);
}
}
class program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello Rahmat Rinaldi 121300032");
cl_masuk masuk = new cl_masuk();
masuk.input();
Console.ReadKey(true);
}
}
}

using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace Exponensial
{
class Program
{
//exp(x) series = 1 + x + x^2 / 2! + x^3 / 3! + x^4 / 4! + x^5 / %! + .....
//exp(x) series = power(2.71828, x)
const double PI = 3.14159265;
const double EulersNumber = 2.71828;
// exp(x) series = 1 + x + x^2 / 2! + x^3 / 3! + x^4 / 4!
static public double MyExp1(double x)
{
double f = x;
double result = 1 + x;
double fact = 1;
int i = 0;
for (i = 2; i < 20; i++)
{
fact *= i;
f *= x;
result += f / fact;
}
return result;
}
// exp(x) series = power(2.71828, x)
public static double MyExp2(double x)
{
return System.Math.Pow(EulersNumber, x);
}
static void Main(string[] args)
{
Console.WriteLine(
"\nsabtu_algo_6_rahmatrinaldi_121300032\n" +
"\nNilai Exp\n" +
DateTime.Now.ToLongDateString() + "\n" +
DateTime.Now.ToLongTimeString() +
"\n\n");
for (double i = -2; i <= 3; i += 0.2)
{
Console.WriteLine("{0,8:f2} = {1,8:f4} {2,8:f4}
System.Math.Exp(i), MyExp1(i), MyExp2(i));
}
Console.ReadLine();
}
}
}

{3,8:f4}", i,

You might also like