Question:

Write a program in C that will read a value from the user and calculate the factorial of that #.

by Guest2666  |  12 years, 9 month(s) ago

0 LIKES UnLike

Use a do loop to keep asking the user to enter values until they enter -1 to quit
Program must be without recursion
If a -# is entered the program should enter and error message and keep looping.

 Tags: calculate, factorial, Program, Read, user, Value, write

   Report

1 ANSWERS

  1. Guest8951
    #include<stdio.h>
    #include<stdlib.h>
    int main()
    {
    int fact,num,i;
    fact=1;
    printf("ENTER WHICH NUMBER YOU WANT TO FACTORIZE\t");
    scanf("%d",&num);
    for(i=0;i<num;i++)
    {
    fact=fact*num;
    num--;
    }
    printf("THE FACTORIZED VALUE IS: %d"fact);
    system("pause");
    return 0;
    }

Sign In or Sign Up now to answser this question!

Question Stats

Latest activity: 14 years ago.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions