GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-Jun-2005, 18:37
sure sure is offline
New Member
 
Join Date: Jun 2005
Posts: 1
sure is on a distinguished road

Writing code for a program in C


Tryin to learn c prog on my own at home.... havin a hard time with a few of the review Q's

What i need to do:


The factorial of a non-negative integer n is written n! (pronounced "n factorial") and is defined as follows:
n! = n * (n-1) * (n-2) * ... * 1 (for values of n greater than or equal to 1)
and
0! = 1
For example 5! = 5*4*3*2*1, which is equal to 120.

Write a program that inputs a non-negative integer and computes and prints its factorial. Use a "while loop" as part of your program implementation. only between 0 and 12 .



heres my psudocode
Code:
/* PSEUDO CODE FOLLOWS: General Statement Compute factorials between 0 and 12 First Refinement 1) Initialize Variables 2) Compute the factorial in a while loop 3) Calculate and print the factorial result Second Refinement 1) Factorial = 1 2) Input num Do print "Enter a positive integer less than 13 input value for n while ( n<0 || n>12 ) 3) Counter = n while (counter>1) factorial = factorial*counter counter = counter - 1 END OF PSEUDO CODE */

thx ...
Last edited by LuciWiz : 08-Jun-2005 at 23:47. Reason: Inserted code tags...
  #2  
Old 09-Jun-2005, 00:24
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
You should read the sticky. You forgot an important posting point, namely you have to ask a question and/or tell us the trouble you are having.
__________________

Age is unimportant -- except in cheese
 
 

Recent GIDBlogToyota - 2008 August Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Guidelines for posting requests for help - UPDATED! WaltP C++ Forum 1 22-Aug-2008 00:07
Problem with int mixed with char,... leitz C++ Forum 17 07-Dec-2004 20:56
Anyone can write a program code for this??? chriskan76 C Programming Language 1 19-Oct-2004 20:25
very difficult code - program gaurav_sting C++ Forum 1 16-Jun-2004 00:59

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:02.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.