| | |
Help needed
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jun 2007
Posts: 8
Reputation:
Solved Threads: 1
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
Lookin forward to your prompt and positive response.
thanks
Notes
do not allow zero as the denomenator
c Syntax (Toggle Plain Text)
#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]
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...
•
•
•
•
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
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
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
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.
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
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
•
•
Join Date: Jun 2007
Posts: 8
Reputation:
Solved Threads: 1
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,
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,
•
•
Join Date: Sep 2006
Posts: 327
Reputation:
Solved Threads: 22
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:
Then if you wanted to store an integer in this variable using scanf,
it would be this:
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.
int numerator a;
You'd have to declare that variable something like this instead:
C Syntax (Toggle Plain Text)
int numerator_a;
it would be this:
C Syntax (Toggle Plain Text)
scanf("%d", &numerator_a);
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.
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
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
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
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
![]() |
Similar Threads
- Harddrive failure and 100% CPU under Win2K, Help Needed! (Windows NT / 2000 / XP)
- XP PRO iis help needed (Windows NT / 2000 / XP)
- CWS. help needed (Viruses, Spyware and other Nasties)
- are all these needed (Windows NT / 2000 / XP)
- help much needed !! (OS X)
Other Threads in the C Forum
- Previous Thread: linker and linkage in c
- Next Thread: Float/Double to String conversion
Views: 1631 | Replies: 9
| Thread Tools | Search this Thread |
Tag cloud for C
* adobe api append array arrays bash binarysearch centimeter char character cm copyanyfile copypdffile createcopyoffile createprocess() csyntax directory drawing dynamic executable execv feet fgets file floatingpointvalidation fork frequency function getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux highest homework i/o ide infiniteloop initialization interest intmain() kilometer lazy license linked linkedlist linux linuxsegmentationfault list match matrix meter microsoft mqqueue multi mysql oddnumber odf open openwebfoundation pause pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition scheduling segmentationfault send shape single socketprogramming spoonfeeding stack standard strchr string strings student suggestions system test testautomation unix urboc user whythiscodecausesegmentationfault win32 win32api windows.h






