Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

factorial loop C++

#include<iostream>

using namespace std;
	
int main(){
    int no = 5;
    
    
    int factorial = 1;
    
    for(int a=no;a>0;--a){     //note: decrement(--)
    factorial *= a ;			// note(*=)
    }
    cout << factorial ;			// 120

}
Source by www.cplusplus.com #
 
PREVIOUS NEXT
Tagged: #factorial #loop
ADD COMMENT
Topic
Name
6+5 =