Results 1 to 10 of 10

Thread: calculate factorial in C++

  1. #1
    MailKing is offline Senior Member+
    Last Online
    19th December 2013 @ 04:05 PM
    Join Date
    17 Aug 2009
    Posts
    400
    Threads
    20
    Credits
    1,030
    Thanked
    19

    Default calculate factorial in C++

    #include <iostream>

    #include <conio.h>

    using namespace std;

    int main()
    {
    int n,f=1;

    cout <<"Enter number for factorial \n";

    cin>> n;

    for(int i=n;i>=1;i--)
    {

    cout << f<<"\n\n";

    f*=i;


    }

    getch();

    return 0;


    }

  2. #2
    qamarnazir's Avatar
    qamarnazir is offline Senior Member+
    Last Online
    27th March 2010 @ 07:33 AM
    Join Date
    06 Nov 2009
    Age
    37
    Posts
    63
    Threads
    3
    Credits
    0
    Thanked
    0

    Default

    this is my favorit subject and i have full command on this
    thanx for contact ---------------
    Last edited by *KHAN*JEE*; 6th June 2010 at 01:22 PM. Reason: Cell Number Removed...

  3. #3
    SulmanQureshi is offline Senior Member+
    Last Online
    13th April 2013 @ 11:07 PM
    Join Date
    22 Jan 2010
    Posts
    156
    Threads
    2
    Credits
    0
    Thanked
    7

    Default

    thanks

  4. #4
    ishwa's Avatar
    ishwa is offline Senior Member+
    Last Online
    15th June 2010 @ 06:17 PM
    Join Date
    04 Jun 2010
    Location
    dil walon ki nagri mein
    Posts
    242
    Threads
    4
    Credits
    0
    Thanked
    3

    Default

    c++ is my favrt subject.
    thanx 4 sharing

  5. #5
    Ganxtr's Avatar
    Ganxtr is offline Advance Member
    Last Online
    5th July 2019 @ 09:15 AM
    Join Date
    15 Nov 2009
    Location
    CRIME CITY
    Posts
    1,740
    Threads
    18
    Credits
    83
    Thanked
    100

    Default

    Great
    your thread is very nice, thanks 4 sharing with us!

  6. #6
    DREAM.KILLER's Avatar
    DREAM.KILLER is offline Advance Member
    Last Online
    1st November 2019 @ 02:21 AM
    Join Date
    12 Sep 2008
    Location
    C:\WINDOW\SYSTEM32
    Posts
    813
    Threads
    141
    Credits
    1,152
    Thanked
    37

    Default

    brother kuch detail b batao na
    i m new

  7. #7
    *Tamraiz*'s Avatar
    *Tamraiz* is offline Advance Member+
    Last Online
    29th August 2022 @ 08:08 AM
    Join Date
    26 Nov 2010
    Location
    Sialkot
    Gender
    Male
    Posts
    16,583
    Threads
    1051
    Credits
    1,207
    Thanked
    1738

    Default

    Nice Sharing

  8. #8
    Shining Star's Avatar
    Shining Star is offline Senior Member+
    Last Online
    25th November 2011 @ 10:38 PM
    Join Date
    02 Dec 2010
    Gender
    Male
    Posts
    201
    Threads
    2
    Credits
    0
    Thanked
    2

    Default

    nice

  9. #9
    wicky1 is offline Junior Member
    Last Online
    2nd October 2015 @ 05:22 PM
    Join Date
    05 Jan 2011
    Age
    32
    Gender
    Male
    Posts
    3
    Threads
    2
    Credits
    935
    Thanked
    0

    Default nice yar

    great job using for statement


    i was tryingit with if else statement

  10. #10
    zapaaris's Avatar
    zapaaris is offline Senior Member+
    Last Online
    30th September 2016 @ 10:27 PM
    Join Date
    11 Feb 2010
    Location
    Karachi
    Age
    39
    Posts
    161
    Threads
    9
    Credits
    241
    Thanked
    33

    Thumbs up

    Quote qamarnazir said: View Post
    this is my favorit subject and i have full command on this
    thanx for contact ---------------
    Sorry bhai...jis ne iss k compiler likhain hain...woh master nahin hota to aap kaisay khud ko kehtay ho k full command hai aap ko....agar aap ziada jantay hain to try karain k yahan jitna ziada ho sakay sikhanay ki kooshash karain,,,,Allah bless u
    aur haan for loop k bahir n ki value ko print karain....iss tarah sirf 1 bar value print ho g

    jaisay


    Code:
    #include <iostream>
    
    #include <conio.h>
    
    using namespace std;
    
    int main()
    {
    int n,f=1;
    
    cout <<"Enter number for factorial \n";
    
    cin>> n;
    
    for(int i=n;i>=1;i--)
    {
    
    
    f*=i;
    
    
    }
    cout << f<<"\n\n";                // print here
    getch();
    
    return 0;
    
    
    }

Similar Threads

  1. Calculate your age ...
    By Asif_Raz in forum C++
    Replies: 14
    Last Post: 22nd March 2018, 11:02 PM
  2. Find Factorial of a number
    By RanaFaheemAg in forum C++
    Replies: 5
    Last Post: 8th May 2015, 12:53 PM
  3. gpa calculate????
    By afza ahmad in forum Ask an Expert
    Replies: 12
    Last Post: 4th April 2014, 11:57 AM
  4. Replies: 8
    Last Post: 8th September 2013, 03:12 PM
  5. factorial
    By waqas urdu in forum Ask an Expert
    Replies: 2
    Last Post: 17th March 2011, 06:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •