473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Code To Output The Factorial Of A Number

1
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. main()
  3. {
  4.     int x,fact=1,counter;
  5. again:printf("Enter a number between 1-10");
  6.       scanf("%d",& x);
  7.       if("x<10||x==1");
  8.       {
  9.           printf("the factorial is....");
  10.  
Im trying to write a code that outputs the factorial of a number between one and ten. I wrote this part but Iam unable to proceed! Please help
Feb 25 '08 #1
3 2085
looker
18
#include<stdio.h>
main()
{
int x,fact=1,counter;
again:printf("Enter a number between 1-10");
scanf("%d",& x);
if("x<10||x==1");
{
printf("the factorial is....");

Im trying to write a code that outputs the factorial of a number between one and ten. I wrote this part but Iam unable to proceed! Please help
The code above is not yet completed, as what you said.
I would say something about your code above:
- You should learn how to use the header file of your project. It is more useful when your code become the library for other to call.
- Define error messages for all of the possible states and bugs
- Never use the number in your C file. it is hard to update your code again when there is a new update on the requirement.
- Be careful in using scanf with integer value inputted. Think of the dummy who will input whatever he/she wants including the char type.
- Learn to divide your functionality into each functions. because it is more easy to call, you need not to code it again.
Feb 25 '08 #2
Please use the search, there was a recent topic about factorials.
Feb 25 '08 #3
hsn
237 100+
i just answered another thread which had the same topic.
just use a loop and you will get the factorial.
Feb 25 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Shashidhar Patil | last post by:
here is the code #include<iostream.h> #include<math.h> #include<conio.h> class legendre { private: int c,b,z,zz,xx,yy,fact; double a,nt,x,y,aa,final,bb,cc;
13
by: Eduardo78 | last post by:
Ok, this is what i am tying to do: I want to create a rutine that takes a value from a text box. Lets say for example 5. and does the following 5*4*3*2*1 = 120 the rutine should be able to...
1
by: Tin | last post by:
Dear Sir/Madam, I have one assignment , which need me to write a program to calculate the factorial of an integer, then press the button that would display the result in a label.3 & the...
18
by: cess | last post by:
i think this is not right!!!! import java.io.*; public class factorial{ public static void main (String args)throws Exception { String number; int numberInteger; int n;
10
by: yusuke | last post by:
can you please answer this:thanks!!! write a factorial function that returns a factorial of a long int number. Enter the number at the main funtion and call factorial() to carry on calculations...
3
by: Sugandh Jain | last post by:
Hi. How to write a function that will return me the factorial (say in a string) for the any positive integer it takes? When we find a factorial of even say 2000 or a higher number, it will be...
13
by: arnuld | last post by:
it runs fine. any advice for the improvement: /* C++ Primer - 4/e * * exercise 7.20 * STATEMENT: * write a programme to find the factorial of an int. * use an iteratice function. * */
1
by: doctor309 | last post by:
hello friends iam not able to get logic behind solving the question mentioned below,,,,i tried a lot using various books.....online tutorials but at the end just lost it...... you ppl are kindly...
3
by: Blue sky | last post by:
Hi,I am a new C++ learner.The follow prgram produces a wrong result,but I can't find the wrong.Can you help me?Thank you! #include<stdio.h> long factorial( long number); int main() { int...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.