Thread: How do I simulate a program with a \frac{}{} command

  1. #16
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,215
    and what is your question?

    no one will do your homework for you.

  2. #17
    Registered User
    Join Date
    Sep 2008
    Posts
    45
    Code:
    what do they mean by simulate a \frac{}{}
    command?

  3. #18
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Integer division gives you the whole number:

    int result, five=5, four=4;
    result = five / four;

    Modulo operator gives you the remainder:

    int rem = five % four;

    Floating point division gives you the fraction:

    float fraction = (float) rem / (float) four;

  4. #19
    Registered User
    Join Date
    Sep 2008
    Posts
    45
    Code:
    #include <iostream>
     using namespace std; 
    int main()
    {   
    double num1;   
    double num2;   
    int n1;   
    int n2;   
    char slash;   
    int spaces = 9 + n1 + n2;    
    
    cout << " enter the fraction asgiven  num1/num2 ";  
    
      cin >> num1 >> slash >> num2 ;   
    
     if ( (num1 >=0) && ( num1 <= 9) )       
    n1 = 1;  
    
    
     else if ( num1 <=99 )     
     n1 = 2     
    
     else	 n
    
    1 = 3;  
    
      if ( ( num2 >=0 ) && ( num2 <=9 ))   
    
    n2 = 1;    
    
        else if ( (  n2  <= 99 )		
    
     n2= 2; 		
    
     else		  
    
      n2= 3  		    
    
       if ( ( n1 > 0 ) && ( n1 > 999 ) ||  ( n2 > 0 ) &&

    What do I do next?

  5. #20
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,215
    fix your indentations next, and choose sensible names for you variables, and post the whole code

  6. #21
    Registered User
    Join Date
    Sep 2008
    Posts
    45
    Code:
    #include <iostream>
     using namespace std; 
    int main()
    {   
    double num1;   
    double num2;   
    int n1;   
    int n2;   
    char slash;   
    int spaces = 9 + n1 + n2;    
    
    cout << " enter the fraction asgiven  num1/num2 ";  
    
      
    cin >> num1 >> slash >> num2 ;   
    
     
    if ( (num1 >=0) && ( num1 <= 9) )       
    n1 = 1;  
    
    
    else if ( num1 <=99 )     
    n1 = 2     
    
    else	
    
    n1 = 3;  
    
    if ( ( num2 >=0 ) && ( num2 <=9 ))   
    
    n2 = 1;    
    
    else if ( (  n2  <= 99 )		
    
    n2= 2; 		
    
    else		  
    
    n2= 3  		    
    
    if ( ( n1 > 0 ) && ( n1 > 999 ) ||  ( n2 > 0 ) &&
    Now?

  7. #22
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,215
    indentation isn't any better, variable names aren't changed, and you are still only posting half the code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 02:42 AM
  2. Chat Program Help?
    By Paul22000 in forum Networking/Device Communication
    Replies: 9
    Last Post: 02-10-2009, 12:35 AM
  3. help
    By hellBOY in forum C Programming
    Replies: 4
    Last Post: 01-13-2009, 11:59 AM
  4. unix `ls' command in C program
    By Moony in forum C Programming
    Replies: 3
    Last Post: 06-28-2006, 11:00 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM
Website Security Test