Activity Stream
48,167 MEMBERS
6737 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 3 of 3
  1.     
    #1
    Member
    Website's:
    scenator.com

    Default C++ help.

    Been having issues with this all night, here's the question.

    Q: Write a program that reads the numerators and denominators of two fractions. Your program should print the numerator and denominator of the fraction that represents the product of the two fractions. Also, print out the percent equivalent of the resulting product.

    So here's my code, I'm pretty sure my math is right. It displays the product of the two fractions properly, but when it comes to the percentage it always gives me 0.00%


    PHP Code: 
    #include <iostream>
    #include<iomanip>
        
    using namespace std
        
    void main()//start main
    {
        
    int n1,n2,d1,d2;
        
    int n,d;
        
    float p;


        
    cout<<"Enter Numerator #1: ";
        
    cin>>n1//First numerator

        
    cout<<"Enter Denominator #1: ";
        
    cin>>d1;//First denominator

        
    cout<<"Enter Numerator #1: ";
        
    cin>>n2//Second numerator

        
    cout<<"Enter Denominator #1: ";
        
    cin>>d2;//Second denominator


        
    n=n1*n2;//Numerator product
        
    d=d1*d2;//Denominator product
        
    p=100//Converts to percent


         

        
    cout<<"Fraction Answer: "<<n;
        
    cout<<"/"<<<<endl;
        
    cout<<"Percentage Answer: "<<fixed << setprecision(2)<<p;
        
    cout<<"%" <<endl;
        
    system("pause");
    }
    //end main 
    jSx@ECD Reviewed by jSx@ECD on . C++ help. Been having issues with this all night, here's the question. Q: Write a program that reads the numerators and denominators of two fractions. Your program should print the numerator and denominator of the fraction that represents the product of the two fractions. Also, print out the percent equivalent of the resulting product. So here's my code, I'm pretty sure my math is right. It displays the product of the two fractions properly, but when it comes to the percentage it always gives me Rating: 5


  2.   Sponsored Links

  3.     
    #2
    Member
    guess:

    Make n1,n2,d1,d2,d and n also FLOAT>.
    Signature removed by staff - Not allowed.

  4.     
    #3
    Member
    Website's:
    scenator.com
    Quote Originally Posted by aswinrm View Post
    guess:

    Make n1,n2,d1,d2,d and n also FLOAT>.
    ooo, thank you very much!


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

BE SOCIAL