How to define a C dataype using structure to store a rational number( fraction of two numbers)? -
how define c datatype using construction store rational number (fraction of 2 numbers).
as have mentioned in comment can create construction store rational number in these way:
1) declaring structure
struct rational_num { int numerator; int denominator; };
to create variable need utilize struct rational_num r1;
2) using typedef structure
typedef struct { int numerator; int denominator; } rational_num;
to create variable need utilize rational_num r1;
c structure
No comments:
Post a Comment