Help needed

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jun 2007
Posts: 8
Reputation: bobs360 is an unknown quantity at this point 
Solved Threads: 1
bobs360 bobs360 is offline Offline
Newbie Poster

Help needed

 
0
  #1
Jun 28th, 2007
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
  1. #include<stdio.h>
  2. 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, ;
  3.  
  4. main()
  5. {
  6. printf("\nËnter value for the numerator a");
  7. scanf("%d",&a);
  8.  
  9. if(numerator a==3)
  10. {
  11.  
  12. printf("Enter value for denomenator b\n");
  13. scanf("%d",&b);
  14.  
  15. if(denomenator b==4)
  16. {
  17. else
  18. {
  19. If (denomenator is 0)
  20. printf("go to again");
  21.  
  22. printf("\nËnter value for the second numerator c");
  23. scanf("%d",&c);
  24. if(numerator c==5)
  25.  
  26. printf("\nËnter value for the second denomenator d");
  27. scanf("%d",&d);
  28. If (denomenator d==3)
  29. {
  30. else
  31. {
  32.  
  33. If (denomenator is 0)
  34. printf("go to again");
  35.  
  36. a/b + c/d
  37.  
  38. bd= b*d
  39.  
  40. x== bd/b*a
  41.  
  42. y== bd/d*c
  43.  
  44. p== x+y
  45.  
  46. if (p>= bd)
  47.  
  48. printf("The whole number is %d, p/bd);
  49. printf("The remainder is %d, p%bd);
  50. }
  51.  
  52. else
  53. {
  54.  
  55. if (p%ab==q)
  56. printf("The remainder is %d, p%q)
  57. }
  58.  
  59. else
  60. {
  61.  
  62. printf("The total sum is %d, p/q);
  63. }
  64. return [o]
Lookin forward to your prompt and positive response.
thanks
Last edited by WaltP; Jun 28th, 2007 at 11:58 am. Reason: Added CODE tags -- you actually typed right over how to use them when you entered this post...
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,124
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 283
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: Help needed

 
0
  #2
Jun 28th, 2007
Originally Posted by bobs360 View Post
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.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,649
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Help needed

 
0
  #3
Jun 28th, 2007
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.
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 8
Reputation: bobs360 is an unknown quantity at this point 
Solved Threads: 1
bobs360 bobs360 is offline Offline
Newbie Poster

Re: Help needed

 
0
  #4
Jun 29th, 2007
Thanks for your prompt reply. Could you please humbly take me through the problem, thanks!
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 8
Reputation: bobs360 is an unknown quantity at this point 
Solved Threads: 1
bobs360 bobs360 is offline Offline
Newbie Poster

Re: Help needed

 
0
  #5
Jun 29th, 2007
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,
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 327
Reputation: Colin Mac is on a distinguished road 
Solved Threads: 22
Colin Mac Colin Mac is offline Offline
Posting Whiz

Re: Help needed

 
1
  #6
Jun 30th, 2007
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:
  1. int numerator_a;
Then if you wanted to store an integer in this variable using scanf,
it would be this:
  1. 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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,649
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Help needed

 
0
  #7
Jun 30th, 2007
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.
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 8
Reputation: bobs360 is an unknown quantity at this point 
Solved Threads: 1
bobs360 bobs360 is offline Offline
Newbie Poster

Re: Help needed

 
0
  #8
Jul 3rd, 2007
Thanks I will
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 8
Reputation: bobs360 is an unknown quantity at this point 
Solved Threads: 1
bobs360 bobs360 is offline Offline
Newbie Poster

Re: Help needed

 
0
  #9
Jul 3rd, 2007
Hi,

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

Regards,

Bobs
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,649
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Help needed

 
0
  #10
Jul 3rd, 2007
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. :-)
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum


Views: 1631 | Replies: 9
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC