Faktorial C++ Source Code

This is source is to find faktorial value, it used a procedural and function.


/*
Name: Faktorial Programm
Copyright: http://tutorialcoding.blogspot.com
Author: Rifki Yandhi
Date: 18/10/09 21:13
Description:
*/
#include <iostream>
#include <conio.h>

using namespace std;

//This is how function is work
int faktorial ( int n )
{
long a = 1;
for ( int i = 1 ; i <= n ; i++ )
{
a = a * i;
}
return a;
}

int main()
{
int n, a = 1;

//input value n from 1 to 15
do
{
cout<<"n! = ";
cin >> n;
}while(n <= 1 && n >= 15 );

//This is how manual way
for ( int i = 1 ; i <= n ; i++ )
{
a = a * i;
}

cout <<"\nManual : "<< n <<"! = "<< a << endl; // this is value from manual way
cout <<"Function : "<< n <<"! = "<< faktorial(n) <<endl; // faktorial(n) is a function that we call from above

getch();
}

Free source code and program download


Using Operator C++ part 2

I have posted about how to using operator in C++, i have remarked it into spesific more with data type float and also integer exactly.

/*
Name: Using operator
Copyright: http://tutorialcoding.blogspot.com
Author: Rifki Yandhi
Date: 18/10/09 21:15
Description:
*/

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
int intA,intB,intProc;
float floatA,floatB;

cout<<"\nImplementation operators +,-,*,/,%"<<endl;
do
{
cout<<"\n1. Data type is Integer"<<endl;
cout<<"2. Data type is Float"<<endl;
cout<<"3. Exit..."<<endl;
cout<<"\nWhat kind of process do you want ? [1,2,3]: ";
cin >> intProc;
}while(intProc > 3 || intProc < 0 );

if ( intProc == 1)
{
cout<<"\n\nYou choose integer data type";
cout<<"\nA = ";
cin >> intA;
cout<<"B = ";
cin >> intB;

cout<<"\n(+) A + B = "<<(intA+intB)<<endl;
cout<<"(-) A - B = "<<(intA-intB)<<endl;
cout<<"(*) A * B = "<<(intA*intB)<<endl;
cout<<"(/) A / B = "<<(intA/intB)<<endl;
cout<<"(%) A % B = "<<(intA%intB)<<endl;

}
else if ( intProc == 2 )
{
cout<<"\n\nYou choose float data type";
cout<<"\nA = ";
cin >> floatA;
cout<<"B = ";
cin >> floatB;

cout<<"\n(+) A + B = "<<(floatA+floatB)<<endl;
cout<<"(-) A - B = "<<(floatA-floatB)<<endl;
cout<<"(*) A * B = "<<(floatA*floatB)<<endl;
cout<<"(/) A / B = "<<(floatA/floatB)<<endl;
}
else
exit(0);

getch();
}



Free source code and program download


Using Operator C++


How to using operator + , - , * , / , % in C++ Language. This is simple source.

/*
Programmed by Rifki Yandhi
Program : Using operator
*/
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
int intA,intB,intC;
intA = 10;
intB = 3;
intC = 150;
cout<<"\nImplementation operators +,-,*,/,%"<<endl;

cout<<"\nA = "<<intA<<endl;
cout<<"B = "<<intB<<endl;

cout<<"\n(+) A + B = "<<(intA+intB)<<endl;
cout<<"(-) A - B = "<<(intA-intB)<<endl;
cout<<"(*) A * B = "<<(intA*intB)<<endl;
cout<<"(/) A / B = "<<(intA/intB)<<endl;
cout<<"(%) A % B = "<<(intA%intB)<<endl;

getch();
}



Free source code and program download

Hello World C++

The first unusual thing a beginner in programming is to create a program to display the words "Hello World". Here is the source code in C++ language to print text "Hello World" plus a name that is inputted into a variable in a command line program / console program.


/*
Programmed by Rifki Yandhi
Program : Hello World
*/
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
char chrName[10];

cout<<"Name : ";
cin >> chrName;

cout<<"\nHello World "<<chrName<<" this is C++ Language";
getch();
}


Screenshoot Program when it was finished compile :


Free source code and program download

First Post

Blog was created.

Please Visit www.tutorialcoding.blogspot.com

Thank's
Rifki Yandhi