I am a beginner in computers, i would like to be assisted in writing a simple program that inputs a fraction in the form of a/b and c/d and culculates the sum and returns the answer in the simlest form as in p/q.

Notes
do not allow zero as the denomenator

#include<stdio.h>
int numerator a, denomenator b, , second numerator c, second denomenator d, first new numerator x, second new numerator y, new denomenator bd, sum of first new numerator x and second new numerator y  p, simplest form of bd, q,  ; 

 main()
{
 printf("\nËnter value for the numerator a");
 scanf("%d",&a);
 
  if(numerator a==3)
  {
  
   printf("Enter value for denomenator b\n");
   scanf("%d",&b);

    if(denomenator b==4)
  {
     else
  {
   If (denomenator is 0)
   printf("go to again");
           
   printf("\nËnter value for the second numerator c");
   scanf("%d",&c);
 if(numerator c==5)

    printf("\nËnter value for the second denomenator d");
   scanf("%d",&d);
   If (denomenator d==3)
  {
     else
  {
  
   If (denomenator is 0)
   printf("go to again");

    a/b + c/d

   bd= b*d
   
   x== bd/b*a

   y== bd/d*c
   
    p== x+y

    if (p>= bd)

     printf("The whole number is %d, p/bd);
     printf("The remainder is %d, p%bd);
    } 
    
    else 
   {
     
    if (p%ab==q)
    printf("The remainder is %d, p%q)
    } 
    
    else 
   {

    printf("The total sum is %d, p/q);
    }
       return [o]

Lookin forward to your prompt and positive response.
thanks

I am a beginner in computers, i would like to be assisted in writing a simple program that inputs a fraction in the form of a/b and c/d and culculates the sum and returns the answer in the simlest form as in p/q.

...

Lookin forward to your prompt and positive response.
thanks

Sure. But you didn't mention what help you need? Is there something wrong with your code?

Also, please read this and this. They will help you get the best help possible.

Looking at your code, I can clearly see that you are desperately struggling with the language. Maybe you should try to get a firm grip over the langauge(or computer science concepts) rather than diving into problems straight away.

This link has some good resources for beginner C programmers.

Thanks for your prompt reply. Could you please humbly take me through the problem, thanks!

Namaste,

Let me outline the problems am having in writing my C program

1. How can one declare two fractions, say a/b and c/d, further as i work through the problem i find myself declaring so many variables, is that normal?
2. Still on declarations, is it ok for one to use a lot of verbatim in doing the same (read declare) trying to explain each and every variable, just having a look at the mess i've done? If its not ok, how should I go about it sighting a simple example?
3. I also have a problem in the last part of the program, giving the the answer in the simplest/reduced form.

Please help me to directly solve this problem at the same time make me learn how to solve future problems,

You can't have whitespace in a variable's name like this:
int numerator a;

You'd have to declare that variable something like this instead:

int numerator_a;

Then if you wanted to store an integer in this variable using scanf,
it would be this:

scanf("%d", &numerator_a);

Notice how the text after the ampersand (&) needs to be the same as how its declared.

It's probably best to go back and get shorter programs working first, before a longer program like this.

Bobs, I would still recommend you to read some good tutorials on C or get some good C books from a store near you to do some reading. Without putting effort or learning on your part, explaining what is wrong and what is right would be too difficult for us.

Please start reading this.

Hi,

Thanks for your reply, what else did you notice wrong?. Please inform me. :-)

Regards,

Bobs

I only noticed that you have just started out with programming. Read good tutorials, practice a lot and come back when you have got specific queries. :-)

This question has already been answered. Start a new discussion instead.