factorial

 


#include <stdio.h>


int main() {

    int fact , i , n ;

    printf("fact of : ");

    scanf("%d",&n);

    fact = 1 ;

    for( i=1 ; i<=n ; i++){

        fact=fact*i;

    }

    printf("%d",fact);

    

    

    return 0;

}


//**********while********


#include <stdio.h>


int main() {

    int fact , i , n ;

    printf("fact of : ");

    scanf("%d",&n);

    fact = 1 ;

    i = 1 ;

    while (i<=n){

        fact=fact*i;

        i=i+1;

        

    }

    

    printf("%d",fact);

    

    

    return 0;

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings