write a program in c++ to find fractional of a number
Answers
Answer:
#include<iostream>
using namespace std;
int main() {
int num,factorial=1;
cout<<" Enter Number To Find Its Factorial: ";
cin>>num;
for (int a=1;a<=num;a++) {
factorial=factorial*a;
Explanation:
INPUT:-
#include <iostream>
#include <iostream>usINPUTing namespace std) {
#include <iostream>usINPUTing namespace std) { int n;
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0;
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: ";
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: "; cin >> n;
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: "; cin >> n; if (n < 0)
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: "; cin >> n; if (n < 0) cout << "Error! Factorial of a negative number doesn't exist.";
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: "; cin >> n; if (n < 0) cout << "Error! Factorial of a negative number doesn't exist."; else {
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: "; cin >> n; if (n < 0) cout << "Error! Factorial of a negative number doesn't exist."; else { for(int i = 1; i <= n; ++i) {
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: "; cin >> n; if (n < 0) cout << "Error! Factorial of a negative number doesn't exist."; else { for(int i = 1; i <= n; ++i) { factorial *= i;
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: "; cin >> n; if (n < 0) cout << "Error! Factorial of a negative number doesn't exist."; else { for(int i = 1; i <= n; ++i) { factorial *= i; }
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: "; cin >> n; if (n < 0) cout << "Error! Factorial of a negative number doesn't exist."; else { for(int i = 1; i <= n; ++i) { factorial *= i; } cout << "Factorial of " << n << " = " << factorial;
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: "; cin >> n; if (n < 0) cout << "Error! Factorial of a negative number doesn't exist."; else { for(int i = 1; i <= n; ++i) { factorial *= i; } cout << "Factorial of " << n << " = " << factorial; }
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: "; cin >> n; if (n < 0) cout << "Error! Factorial of a negative number doesn't exist."; else { for(int i = 1; i <= n; ++i) { factorial *= i; } cout << "Factorial of " << n << " = " << factorial; } return 0;
#include <iostream>usINPUTing namespace std) { int n; long double factorial = 1.0; cout << "Enter a positive integer: "; cin >> n; if (n < 0) cout << "Error! Factorial of a negative number doesn't exist."; else { for(int i = 1; i <= n; ++i) { factorial *= i; } cout << "Factorial of " << n << " = " << factorial; } return 0;}