A program to ask the user a number and then the program will compute the factorial number using pointers in C++ programming language.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Please subscribe to my channel https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg
=================================================
Want to support my channel?
GCash Account
Jake Pomperada
09173084360
Paypal
https://paypal.me/jakerpomperada
Patreon
https://www.patreon.com/jakerpomperada
Thank you very much for your support.
Program Listing
#include <iostream>
using namespace std;
int Solve_Factorial(int n, long int *factorial){
int i;
*factorial =1;
for(i=1;i<=n;i++)
*factorial=*factorial*i;
}
int main(){
long int factorial;
int num_given=0;
cout <<"\n\n";
cout <<"\tFactorial a Number Using Pointers in C++";
cout <<"\n\n";
cout <<"\tGive a Number : ";
cin >> num_given;
Solve_Factorial(num_given, &factorial);
cout <<"\n\n";
cout <<"\tFactorial of " << num_given
<< " is " << factorial << ".";
cout <<"\n\n";
cout << "\tEnd of Program";
cout <<"\n";
}
No comments:
Post a Comment