Search
 
SCRIPT & CODE EXAMPLE
 

C

fraction sum c

/** Struct describing a Fraction */
typedef struct Fraction
{
    int num; // numerator
    int den; // denominator
} Fraction;

Fraction frc_sum(Fraction a, Fraction b)
{
    const int lcm = frc_lcm(a,b);

    Fraction f = {(a.num * lcm/a.den) + (b.num * lcm/b.den), lcm};
    //frc_simplify(&f);

    return f;
}

// IN MAIN
Fraction f1 = {1,3};
Fraction f2 = {1,6};
frc_print(frc_sum(f1, f2));
Comment

fraction sum c

/** Struct describing a Fraction */
typedef struct Fraction
{
    int num; // numerator
    int den; // denominator
} Fraction;

Fraction frc_sum(Fraction a, Fraction b)
{
    const int lcm = frc_lcm(a,b);

    Fraction f = {(a.num * lcm/a.den) + (b.num * lcm/b.den), lcm};
    //frc_simplify(&f);

    return f;
}

// IN MAIN
Fraction f1 = {1,3};
Fraction f2 = {1,6};
frc_print(frc_sum(f1, f2));
Comment

PREVIOUS NEXT
Code Example
C :: Macro definition and expansion 
C :: __isoc99_sscanf 
C :: how many archaeologists are there 
C :: float para numeros aleatorios em c 
C :: Integer Output 
C :: reverse binary tree c 
C :: redis endpoint 
C :: c program for airthmetic operators 
C :: adding three numbers in c 
C :: get file ligne count c 
C :: how to know a type of a numbe in c 
C :: wpdb add temporary while drop table 
C :: os.listdir to array 
C :: creating an array of arrays or 2D array dynamically 
C :: exponent calculator 
C :: QDrag and Drop 
C :: countoddevenDifference 
C :: c pass two dimensional array to function 
C :: how to compare string in c 
C :: Recommended compiler and linker flags for GCC 
Dart :: listview.separated flutter 
Dart :: flutter divider 
Dart :: rupee icon in flutter 
Dart :: raised button deprecated flutter 
Dart :: flutter auto height container 
Dart :: flutter analyze apk size 
Dart :: how to repeatedly call a function flutter 
Dart :: flutter var type 
Dart :: RenderFlex overflowed 
Dart :: flutter disable horizontal 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =