Thread: Basic Factorial from 1-10

  1. #16
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    no biggie. Just making sure.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  2. #17
    Registered User
    Join Date
    May 2005
    Posts
    11
    ItsMe and FillYourBrain: Thanks a ton for your help. I really appreciate it. I'm going to look at these examples and apply them to my exercise. Again, sorry for my stubborness. I'm still a rookie at this. I appreciate the patience.

    Cheers!

  3. #18
    Registered User
    Join Date
    May 2005
    Posts
    207
    Hey, wow! I'm learning factorials too! That was an awesome factorial program!

    How does the *= work?

    Thanks!

    mw
    Last edited by Lionmane; 05-24-2005 at 10:14 PM.

  4. #19
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    x *= y is short hand for x = x * y
    Same rule applies to += -= /= %= ^= &= etc

  5. #20
    BellA_RoSa
    Join Date
    May 2005
    Posts
    8

    Cool fine

    fine I guess I should have given more explaination 2 my code :P
    ok I assumed that the user would want to tell the program which numbers it wants it to find the factorial to :P

    Code:
    int i  , sum = 1 ; 
    
    printf("Enter value");
    scanf("%d" , & value );
    
    for ( i = value ; i  > 0 ; i-- )
    sum = sum * i ;
    
    printf("The result is % d \n" , sum );
    so if the user enters 5 for example it would resul in
    5 * 4 * 3 * 2 * 1 = 120 :P
    sorrry if i caused loads of cunfusion !! :P:P:P:P

  6. #21
    BellA_RoSa
    Join Date
    May 2005
    Posts
    8

    Talking oh yeah

    Also forgot to declaure value as int :P
    Code:
     
    
    
    int main()
    {
    int i , value , sum = 1 ; 
    
    printf("Enter value");
    scanf("%d" , & value );
    
    for ( i = value ; i  > 1 ; i-- )
    sum = sum * i ; 
    
    printf("The result is % d \n" , sum );
    
    return(0);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A-Star Pathfinding
    By mike_g in forum General AI Programming
    Replies: 1
    Last Post: 08-05-2007, 04:18 PM
  2. Weird error whith strstr
    By OnionKnight in forum C Programming
    Replies: 4
    Last Post: 02-12-2005, 08:58 PM
  3. linked list problem
    By kzar in forum C Programming
    Replies: 8
    Last Post: 02-05-2005, 04:16 PM
  4. working out
    By ZakkWylde969 in forum A Brief History of Cprogramming.com
    Replies: 35
    Last Post: 11-29-2003, 01:17 PM
  5. Basic To C++ Converter
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 11-01-2001, 05:14 PM