Answer to Question #269307 in C++ for Mulaudzi Muano

Question #269307

c++ program to find the factorial of any number between 3 and 9

1
Expert's answer
2021-11-21T17:34:11-0500
#include<iostream>
using namespace std;
int main(){
	cout<<"Enter a number between 3 and 9\n";
	int n;
	cin>>n;
		int fact =1;
	switch(n){
		case 3 ... 9:
		
			for(int i=1; i<=n; i++){
				fact *= i;
			}
			cout<<"The factorial of "<<n<<"  is "<<fact<<endl;
			break;
		default:
			cout<<"The number should be between 3 and 9 "<<endl;
	}
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS