previous paper solutions: JNTU 2016 december : factorial


#include <stdio.h>
void main()
{
    /*variable declaration*/
    int i=1, N;
    long int  facto=1;//facto will contain the factorial of N
    //i is used as counter variable
  printf("\n enter a non negitive integer as we want to compute factorial");
    printf("\n enter the value of N whose factorail is required:");
    scanf("%d",&N);
    /*computing the factorial begins*/
    while(i<=N)
    {
        facto=facto*i;
        i++;
    }
    /*displaying the output*/
    printf("\n the factorial of given no. %d is %ld",N, facto);
}
    

----
// Online C compiler to run C program online
#include <stdio.h>
void main()
{
    /*variable declaration*/
    int i=1, N;
    long int  facto=1;//facto will contain the factorial of N
    //i is used as counter variable
  printf("\n enter a non negitive integer as we want to compute factorial");
    printf("\n enter the value of N whose factorail is required:");
    scanf("%d",&N);
    /*computing the factorial begins*/
    do
    {
        facto=facto*i;
        i++;
    }while(i<=N);
    /*displaying the output*/
    printf("\n the factorial of given no. %d is %ld",N, facto);
}
   
---- 
enter the value of N whose factorial is required:5
the factorial of given no. 5 is 120 

కామెంట్‌లు

ఈ బ్లాగ్ నుండి ప్రసిద్ధ పోస్ట్‌లు

100% C prog to write content into a file and then read it back onto the console

Spic macay

శ్రీరస్తు.. రామలింగ 18-1-24 (సూరసాని వారి ఆహ్వానము)