Forum Replies Created
- AuthorPosts
- msaqibParticipant
Hello, you have done the following things wrong:
in the function definition ; is not allowed void rational::printrationald() also you will need to correct the variable name denominator I hope now your problem will be solved.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118#include<br />using std::cout;<br />using std::endl;<br />class rational{<br />public:<br />rational (int=0, int=1);<br />rational addition (const rational &);<br />rational subtraction (const rational &);<br />rational multiplication (const rational &);<br />rational division (const rational &);<br />void printrational();<br />void printrationald();<br />private:<br />int numerator;<br />int denominator;<br />void reduction();<br />};<br />rational :: rational(int n, int d){<br />int numerstor=n;<br />int denominator =d;<br />}<br />rational rational ::addition (const rational &s){<br />rational w;<br />w.numerator= s.numerator*denominator;<br />w.numerator+=s.denominator*numerator;<br />w.denominator=s.denominator*denominator;<br />w.reduction();<br />return w;<br />}<br />rational rational:: subtraction(const rational &r){<br />rational w;<br />w.numerator= r.numerator*denominator;<br />w.numerator-=r.denominator*numerator;<br />w.denominator=r.denominator*denominator;<br />w.reduction();<br />return w;<br />}<br />rational rational ::multiplication (const rational &j)<br />{<br />rational w;<br />w.numerator= j.numerator*denominator;<br />w.denominator=j.denominator*denominator;<br />w.reduction();<br />return w;<br />}<br />rational rational ::division (const rational &k)<br />{<br />rational w;<br />w.numerator= k.numerator*denominator;<br />w.denominator=denominator*k.denominator;<br />w.reduction();<br />return w;<br />}<br />void rational::printrational()<br />{<br />cout<<numerator<<'t'<<denominator;<br />}<br /><strong>void rational::printrationald(); // you should write like that void rational::printrationald() without the ;</strong><br />{<br /><strong>cout<<numerator'/'<<denomirator; //spellings for denomirator are wrong you should write denominator</strong><br />}<br />void rational:: reduction()<br />{<br />int s;<br />s=numerator<denominator?numerator:denominator;<br />int x=0;<br />for (int l=2; l<=s;++l)<br />if (numerator % l == 0 && denominator % l)<br />x= l;<br />if (x!= 0)<br />{<br />int numinator = x;<br />int denominator = x;<br />}<br />} int main()<br />{<br />rational a(1, 7), f(9,2), h;<br />a.printrational();<br />cout<<"+";<br />f.printrational();<br />h= a.addition(f);<br />cout<<"=";<br />h.printrational();<br />cout<<'n';<br />h.printrational();<br />cout<<"=";<br />h.printrationald();<br />a.printrational();<br />f.printrational();<br />h=a.subtraction(f);<br />cout<<"=";<br />h.printrational();<br />cout<<'n';<br />h.printrational();<br />cout<<"=";<br />h.printrationald();<br />a.printrational();<br />cout<<"h";<br />f.printrational();<br />h=a.multiplication(f);<br />cout<<"=";<br />h.printrational();<br />cout<<'n';<br />h.printrational();<br />cout<<'=';<br />h.printrationald();<br />a.printrational();<br />f.printrational();<br />h=a.division(f);<br />cout<<"=";<br />h.printrational();<br />h.printrational();<br />cout<<"=";<br />h.printrationald();<br />cout<<endl;<br />return 0;<br />}<br />msaqibParticipantspsinghs plz can u give an overview of this program, I mean the flow of the program, So that novice users can understand it.
ThanksmsaqibParticipantNice effort spsinghs.
msaqibParticipantThanks for your support.
I have’t tried this code due to some business, After testing this code I will again ask for your support.
SaqibmsaqibParticipantCan you Please give some code sample, to do this.
Actually I have never beeen into this area.msaqibParticipantI think go to some programming website like this one,
here are some cool links for learning programming.
https://www.cprogramming.com/
https://geeksforgeeks.org/
https://programmersheaven.com/msaqibParticipantWriting windows programs in C/C++ can be a bear for even experienced programmers. I started out with the DEV C++ package and quickly switched to BCX. This is a basic to C/C++ translator that uses simple basic code and allows inline asm and C code. If you are familiar with basic you can then look at the generated C/C++ code and learn a lot!
Write your basic code on the included editor and compile and run it from the editor or even fancier, from the included visual IDE. This program has excellent help files and a good selection of examples. You can look at the C code it produces. You can make win-gui or console programs. BCX is written in BCX!
The whole free package can be downloaded, including the PellesC compiler, from:
There is quite a nice group of users at
msaqibParticipanthere is a link to a compiler called dev c++ it is free.
http://www.bloodshed.net/devcpp.html
if you want a better compiler and are willing to spend money than i suggest the borland compiler.
msaqib 38266.5445949074 msaqibParticipantThe (STL) is a general-purpose C++ library of algorithms and data structures, originated by Alexander Stepanov and Meng Lee. The STL, based on a concept known as generic programming, is part of the standard ANSI/ISO C++ library. The STL is implemented by means of the C++ template mechanism, hence its name. While some aspects of the library are very complex, it can often be applied in a very straightforward way, facilitating reuse of the sophisticated data structures and algorithms it contains.
A complete introduction to the STL can be found by consulting the references below. For starters, though, a small number of classes and algorithms can be very useful:
- The string class
The vector container template
The sort algorithm
The list container template
The iterator classes
The find algorithmThanks
Saqib
MYCPLUS Online CommunitymsaqibParticipantActually its a new site and still growing
As the time passes the people will take interst in the site
Inshallah
msaqibParticipantAmir welcome to MYCPLUS Online Community Forums. Thanks that you like the design of the website. Here is what you asked, hopefully you will understand. If there is anyone who can ad more to it I will appriciate.
GETCHAR:
getchar is a macro defined in (stdin), getchar returns the next character on the input stream stdin.
It returns the character read, after converting it to an int without sign extension. If there is error reading the character or (and on end-of-file for getchar), it returns EOF.1Declaration: int getchar(void);12345678910#include <stdio.h><br />int main(void)<br />{<br />int c;<br />/* Note that getchar reads from stdin and is line buffered;<br />this means it will not return until you press ENTER. */<br />while ((c = getchar()) != 'n')<br />printf("%c", c);<br />return 0;<br />}GETCH:
getch gets a character from console but does not echo ( write ) to the screen. It reads a single character directly from the keyboard, without echoing
to the screen. getche reads a single character from the keyboard and echoes it to the current text window, using direct video or BIOS. Both functions return the character read from the keyboard.
Declaration:12int getch(void);<br />int getche(void);12345678910111213141516<br />#include <conio.h><br />#include <stdio.h><br />int main(void)<br />{<br />int c;<br />int extended = 0;<br />c = getch();<br />if (!c)<br />extended = getch();<br />if (extended)<br />printf("The character is extendedn");<br />else<br />printf("The character isn't extendedn");<br />return 0;<br />}GETC:
getc is a macro that gets one character from a stream. It returns the next character on the given input stream and increments the stream’s file pointer to point to the next character.It returns the character read, after converting it to an int without sign extension. If there is error (and on end-of-file for getc), both functions return EOF.1Declaration: int getc(FILE *stream);123456789101112#include <stdio.h><br />int main(void)<br />{<br />char ch;<br />printf("Input a character:");<br />/* read a character from the<br />standard input stream */<br />ch = getc(stdin);<br />printf("The character input was: '%c'n", ch);<br />return 0;<br />}<br /> - AuthorPosts