# Thread: Need help woth fractions..

1. ## Need help woth fractions..

Hi! i am new to C, so i want your help about a program. Could someone post any code on how to add two fractions, and checking the case of the zero denominator...thanks!

my code is:

Code:
```#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main()
{
int a, b, c, d;
char dummychar;
int divisor, divident;

printf( "Enter First divisor:");
scanf("%d",&a);
printf("\n");

printf("Enter the First divident:");
scanf("%d",&b);
printf("\n");

printf( "Enter second divisor:");
scanf("%d",&c);
printf("\n");

printf( "Enter second divident:");
scanf("%d",&d);
printf("\n");

divisor = a*d + b*c;
divident = b+d;```
how can i print the result..and how can i use an if statement to checking for zero divident?

2. comparisons in c work like this
Code:
```if(conditional) {
code to be executed if conditional is true
}```
You can work that into your program, then to print use printf.

3. yes, i know that, could you send me the code plz..

4. First of all, stick to C code if you're going to post on this forum, not C++. Second of all, we don't just do homework for people. Telling you how to use programming as a tool is one thing, but handing out finished code is quite another.

5. snapshooter you have a little error there
Code:
```a   c   a*d   c*b   a*d+c*b
- + - = --- + --- = -------
b   d   b*d   d*b     b*d

divisor = a*d + b*c;
divident = b*d;```