Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,352 members, 7,808,229 topics. Date: Thursday, 25 April 2024 at 09:07 AM

Check In: Submit Your C++ Questions Lets Solve - Programming (3) - Nairaland

Nairaland Forum / Science/Technology / Programming / Check In: Submit Your C++ Questions Lets Solve (5766 Views)

Mybb Expert Needed: Please Check In Here / Please I Get This Error When Submit Form (notice: Undefined Index) (2) (3) (4)

(1) (2) (3) (Reply) (Go Down)

Re: Check In: Submit Your C++ Questions Lets Solve by BlueMagnificent(m): 11:43pm On Jul 05, 2015
jacob05:
main.cpp


/*
* File: main.cpp
* Author: pyjac
*
* Created on June 30, 2015, 1:51 AM
*/

#include <cstdlib>
#include <iostream>
#include "fraction.h"
#include <cassert>

using namespace std;


/*
*
*/
int main(int argc, char** argv) {

Fraction a(3,1,2);
Fraction b(2,3);
Fraction c(4,5);
Fraction d(4);
Fraction e(6,2);
Fraction f(9,6,8 );

Fraction g = a + b - c * d / e -f;
cout << "Solution: " << g <<endl; // -133/20
return 0;
}

Nice one
Re: Check In: Submit Your C++ Questions Lets Solve by jacob05(m): 7:06am On Jul 06, 2015
BlueMagnificent:


Nice one
Thanks boss
Re: Check In: Submit Your C++ Questions Lets Solve by 1stdami(m): 8:45am On Jul 06, 2015
jacob05:
main.cpp


/*
* File: main.cpp
* Author: pyjac
*
* Created on June 30, 2015, 1:51 AM
*/

#include <cstdlib>
#include <iostream>
#include "fraction.h"
#include <cassert>

using namespace std;


/*
*
*/
int main(int argc, char** argv) {

Fraction a(3,1,2);
Fraction b(2,3);
Fraction c(4,5);
Fraction d(4);
Fraction e(6,2);
Fraction f(9,6,cool;

Fraction g = a + b - c * d / e -f;
cout << "Solution: " << g <<endl; // -133/20
return 0;
}

www.nairaland.com/attachments/2566275_imag20251_jpeg289e6d9aae576e422a9704ae0757fd0e

REF : http://www.math.ucla.edu/~wittman/10a.1.10w/ccc/ch17/index.html


CC pcguru1 1stdami BlueMagnificent seunthomas


hmm nice code lemme run it on my complieer

1 Like

Re: Check In: Submit Your C++ Questions Lets Solve by jacob05(m): 10:04am On Jul 06, 2015
1stdami:



hmm nice code lemme run it on my complieer
ok.
Re: Check In: Submit Your C++ Questions Lets Solve by 2mNaira: 7:45pm On Jul 06, 2015
1stdami:



hmm nice code lemme run it on my complieer


This is a good.effort. d big issue is how it gets input. until ur program starts by readg input and parsing dm for token, it is not real world program.Nice effort though.
Re: Check In: Submit Your C++ Questions Lets Solve by nembudziya(m): 7:47pm On Jul 06, 2015
gmus:


Files(i.e. disk),console, and printer are examples of devices.

cout writes to stdout by default which is d console. It can be redirected to write to any other output device.

If u wish to write to a device and retrieve later dn dt device must neccesatily be a file.
thanks bro. But i did not understand the part about stdout being a console because i have seen some programs in c++ where stdout is not used. Exactly what is the purpose of this console (stdout). I also don't understand the dn dt, are they standard c++ words or its your way of writing then that, because strictly speaking i have seen somewhere dt was used as a standard c++ word just like int. So furnish me please. Bros, i have seen and respect that you are a progressive c++ expert, and thank you for that.
Re: Check In: Submit Your C++ Questions Lets Solve by nembudziya(m): 7:56pm On Jul 06, 2015
gmus:



See this:
https://en.m.wikipedia.org/wiki/Console_application


I know dt the ofstream object is a stream. it is like an interface btw a program and and a device. When u write with ofstream u are not writng to a devicr. You are writing to a stream. Files and printers are examples of devices.



POST EDIT:
Download and read ; C++: The Complete Reference by Hebert Sheildt 4th Edition.

U can also check my post in my main nairaland account - mnairaland
ok thanks bro. But when i read the link, being a beginner programmer as i am, i feel like ms word is a type of console application. Please help me understand there, thank you.
Re: Check In: Submit Your C++ Questions Lets Solve by nembudziya(m): 8:02pm On Jul 06, 2015
codemarshal08:

It seems you are a beginner programmer. I will advice you get a good c++ book as Jacob Suggested. These things are not as complex as you think.
C++ is not a language u rush over. just take your time and learn the damn Beast !
yeah, i guess so...... I am afraid i am going to spend the better part of my time trying to grasp c++, and by the time i reach......yrs i def must an expert. I tried reading the deitel and harvey text book, but man, i could not understand the jargon, but at least it got me thinking otherwise, anyways thanks bros.
Re: Check In: Submit Your C++ Questions Lets Solve by codemarshal08(m): 8:08pm On Jul 06, 2015
nembudziya:
yeah, i guess so...... I am afraid i am going to spend the better part of my time trying to grasp c++, and by the time i reach......yrs i def must an expert. I tried reading the deitel and harvey text book, but man, i could not understand the jargon, but at least it got me thinking otherwise, anyways thanks bros.

yea, it isn't strange to feel that way. Every Pro u see speaking Codes was once in your stage. Just relax, define your goals and work your way to the top . its a step by step matter. Do check the book Jacob05 recommended, it will really get u started with Programming in general !


Note: read less and Practice more !
Re: Check In: Submit Your C++ Questions Lets Solve by BlueMagnificent(m): 8:15pm On Jul 06, 2015
codemarshal08:
Note:read less and Practice more
Exactly... And don't forget to study source codes you might come across
Re: Check In: Submit Your C++ Questions Lets Solve by 2mNaira: 8:22pm On Jul 06, 2015
nembudziya:
thanks bro. But i did not understand the part about stdout being a console because i have seen some programs in c++ where stdout is not used. Exactly what is the purpose of this console (stdout). I also don't understand the dn dt, are they standard c++ words or its your way of writing then that, because strictly speaking i have seen somewhere dt was used as a standard c++ word just like int. So furnish me please. Bros, i have seen and respect that you are a progressive c++ expert, and thank you for that.



Friend: cout is a.stream. it can be linked to any device.The device dt cout is currently linked to is called stdout. it could be a printer, file, console or any other device.
Compiler writer usually set d console as d divice dt cout is currently linked to i.e. they link cout to d console by default.You can change dt if u wish.
Re: Check In: Submit Your C++ Questions Lets Solve by nembudziya(m): 8:26pm On Jul 06, 2015
codemarshal08:


yea, it isn't strange to feel that way. Every Pro u see speaking Codes was once in your stage. Just relax, define your goals and work your way to the top . its a step by step matter. Do check the book Jacob05 recommended, it will really get u started with Programming in general !


Note: read less and Practice more !

thanks bro.
Re: Check In: Submit Your C++ Questions Lets Solve by nembudziya(m): 8:32pm On Jul 06, 2015
mnairaland:




Friend: cout is a.stream. it can be linked to any device.The device dt cout is currently linked to is called stdout. it could be a printer, file, console or any other device.
Compiler writer usually set d console as d divice dt cout is currently linked to i.e. they link cout to d console by default.You can change dt if u wish.

thanks, bro.
Re: Check In: Submit Your C++ Questions Lets Solve by nembudziya(m): 8:34pm On Jul 06, 2015
mnairaland:




Friend: cout is a.stream. it can be linked to any device.The device dt cout is currently linked to is called stdout. it could be a printer, file, console or any other device.
Compiler writer usually set d console as d divice dt cout is currently linked to i.e. they link cout to d console by default.You can change dt if u wish.

thanks bro.
Re: Check In: Submit Your C++ Questions Lets Solve by 2mNaira: 8:42pm On Jul 06, 2015
nembudziya:
ok thanks bro. But when i read the link, being a beginner programmer as i am, i feel like ms word is a type of console application. Please help me understand there, thank you.

Generally. There two types of applicatns : console and non-console.

A console applicatn is an application whose user output is directed at d console.
A non-console application is an application whose user output is not directed to d console.Usually their output is direct to a window. While windows are graphical output envirinment consoles are not.

Using windows as an example, there two types of applicatns: console applications and windows appkicatn.MS Word is.a. windows applicatn.

My professional advice to u is to stop askg these elementary questns. Get a book and read.That is.a professional advice.

Download and read :Beginnes Guide to C++ by Herbert Sheidt.

Note: There are good and bad books for learng C++. The ones i have recommemded are good books.
Re: Check In: Submit Your C++ Questions Lets Solve by nembudziya(m): 9:09am On Jul 07, 2015
mnairaland:


Generally. There two types of applicatns : console and non-console.

A console applicatn is an application whose user output is directed at d console.
A non-console application is an application whose user output is not directed to d console.Usually their output is direct to a window. While windows are graphical output envirinment consoles are not.

Using windows as an example, there two types of applicatns: console applications and windows appkicatn.MS Word is.a. windows applicatn.

My professional advice to u is to stop askg these elementary questns. Get a book and read.That is.a professional advice.

Download and read :Beginnes Guide to C++ by Herbert Sheidt.

Note: There are good and bad books for learng C++. The ones i have recommemded are good books.
ok, thank you, bros. I will def download the book.
Re: Check In: Submit Your C++ Questions Lets Solve by bowofolu(m): 6:42am On Jul 14, 2015
nembudziya:
ok, thank you. Suppose i return 0,what part of the code you suggest i put the command

You can call the system function and pass the commands as parameters.
system("notepad /p your_file.txt");

Remember to #include <stdlib.h>
You'll need that for the system(); function.
Re: Check In: Submit Your C++ Questions Lets Solve by nembudziya(m): 7:21pm On Jul 14, 2015
Thank you, i will try that out.

bowofolu:


You can call the system function and pass the commands as parameters.
system("notepad /p your_file.txt");

Remember to #include <stdlib.h>
You'll need that for the system(); function.
Re: Check In: Submit Your C++ Questions Lets Solve by nembudziya(m): 9:01pm On Jul 18, 2015
Thanks G.

bowofolu:


You can call the system function and pass the commands as parameters.
system("notepad /p your_file.txt");

Remember to #include <stdlib.h>
You'll need that for the system(); function.
Re: Check In: Submit Your C++ Questions Lets Solve by S4MSON(m): 6:53am On Jul 19, 2015
Has anyone here ever implemented any AI algorithm please?, I'm trying to get around Bayesian network
Re: Check In: Submit Your C++ Questions Lets Solve by bowofolu(m): 7:16pm On Jul 20, 2015
nembudziya:
Thanks G.


Your welcome, buddy. wink

(1) (2) (3) (Reply)

How Long Did It Take U'all To Learn Programming? 10 Years? / Php Challenge: External Authentication Of Phpbb3 / Android App Developers Charges

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 39
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.