Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,878 members, 7,956,317 topics. Date: Monday, 23 September 2024 at 09:52 AM |
Nairaland Forum / Science/Technology / Programming / C++ Tutorial For Beginners... Part 1... (19480 Views)
C++ Tutorial Download Link / Java Tutorial For Beginners / Free C++ Tutorial Videos (2) (3) (4)
(1) (2) (3) (4) (5) (6) (Reply) (Go Down)
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 6:39pm On Oct 13, 2014 |
haxorDelite: |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:52pm On Oct 13, 2014 |
zyzxx: THANKS BRO..... I REALLY APPRECIATE... 1 Like |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 10:20pm On Oct 13, 2014 |
Hey guys, did you find your first code interesting? well, it was fun to me cause i debugged my code and it worked properly, you can't challenge the experts for now, our journey just began. i wanted to start with java, then moved to Android app programming where you can create cool apps compatible with Android devices, but i opted to start with Cplusplus..and i can see we are having fun, aren't we? well, i cant leave you guys with just one example and with over 200 views and going to make the next program even more interesting... am a lover of physics, so today example we will deal with a problem in physics... PROBLEM 2: The Force of attraction between two charges is directly proportional to the product of its charges and is inversely proportional to the square of their distance.... write a program that can find the magnitude of the force? using cpp... ( please i did physics a long time ago, i cant really remember the law but i hope i stated it correctly< if not, pls feel free to correct me) thank you... SOLUTION... First, am sorry if your not a physics student but i only created this problem to show you how we can also apply cpp to physics. i bet you will find this interesting... don't be overwhelmed by the grammar, just hold my hands and follow my lead... Outline...... ( before i proceed let me update the current scoreline.... men 5 - women 0... yeah,, ladies you haven't contributed anything yet,, later you yell what a man can do a woman can do it better) ... lol lets get back to business,,, upload shortly.... 1 Like |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 11:09pm On Oct 13, 2014 |
please guys, i need more comments, more sharing, more questions and suggestions... thank you note: am using blue text format because am a chelseafc fan lmao......... OUTLINE.... hmm, just as we did to the first problem, we repeat again... writing an outline helps a lot in building programs.... let me break that problem down, the formula is F= K(Q1*Q2)/R^2 OR F= K(Q1*Q2)/(R*R) WHERE F= FORCE (NEWTON) (N) K=CONSTANT ( assume is on air) (9.0 x 109 N • m*m / C*C) Q1= CHARGE OF THE FIRST FIRST PARTICLE unit Coulombs (C) Q2= CHARGE OF THE SECOND PARTICLE unit coulombs (C) R= RADIUS/ DISTANCE BETWEEN CHARGES...( m^2) *1 Aim: Program able to find the magnitude of the force of attraction between two bodies.. *2 Header files: suitable header files includes #include <math.h> ( because we might need some mathematical operations) #include <cstdio> #include < iostream> ( because we require our program to get input/information from the user.. *3 NATURE: we need to ensure that the units are correct and complete, we can solve this problem breaking down into numerator(constant multiplying the product of charges and denominator( radius raise to power 2)... *4 INPUTS : this program will requires 3 inputs from the user, note ( k is a constant and wont change, it will just sit there laughing lmao), ( but the main input are (Q1,Q2 , AND R). *5 OUTPUT(S): this program will require just one major output which is "F=force" *6 MATHEMATICAL SIGNS REQUIRED: from the nature of the problem, we can find four (4) signs namely ( Equal sign , pair of bracket, multiplication and as well division..) *7 VARIABLE TYPE : " double" WILL BE VERY SUITABLE, DON'T USE "int" ( to avoid truncation error)... *8 UNITS: it is important to ensure the units are correct.... to make this program simple lets assume no conversion where to be needed)...... what you see is just a mere outline, gives a feasibility study of what our program entails.... i will post solution as soon i get five (5) comments from the new or existing followers....... 5 Likes 5 Shares |
Re: C++ Tutorial For Beginners... Part 1... by haxorDelite(m): 9:32am On Oct 14, 2014 |
Ezechinwa:God Bless you for me.. Keep up the tut we're following bumper to bumper |
Re: C++ Tutorial For Beginners... Part 1... by swscorpio: 4:22pm On Oct 14, 2014 |
Ezechinwa: |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 5:43pm On Oct 14, 2014 |
You guys rock... ( let me share a little fact about myself, Am a final year student in a federal uni in Nigeria, Have been programming for roughly 2 years now, all have learnt about programming is just via reading few books & practising on my personal laptop... it wasn't easy, but it ws worth the effort.... pls don't get me wrong, am not saying going to tutor centers like Niit, afrihub etc is bad, no.. but am only saying, if you dont have the money to learn, there are free tools, books etc you can read and improve... @javanian your the best, i learnt a lot on nl ) if you are enjoying CPlusplus.. wait till i show u Java.... for me, Java is the best programming language ever.. ) once again, i really appreciate the likes and the shares,, it may be little for now, but it shows that am touching someone's life out there... note... if your a good graphic designer, send me a pm,,, on facebook or tweet me @xbox360fan... lets work together... and develop andriod apps... The solution to the next problem is coming up soon.. as soon as i get home... so stay tuned... God bless Nairaland... 3 Likes 1 Share |
Re: C++ Tutorial For Beginners... Part 1... by haxorDelite(m): 7:13pm On Oct 14, 2014 |
I got a question, can one build a web app with c++ |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:01pm On Oct 14, 2014 |
[color=#006600] hope you guys didn't miss me that much, lol, well, so far, we have dealt with only one example... but now, we have another tactical problem on our hands... we have just an outline, so lets apply it... tools to solve this problem.. 1. get a calculator / use your mobile phone. 2. switch on your pc, and open ur compiler. 3. get a cup of tea, relax and enjoy.. note:: look carefully at the constant K, it has a valve of 9 * 10 ^ 9.. prononced ( nine times ten raise to the power of 9).., we also assumed that our user won't enter a wrong unit, hence no conversion needed.... therefore K=constant= 9,000,000,000 n*m*m/c*c.... pls if that valve isnt correct, you can correct me ... i crammed dat formula since my sec school days.. lol.. note: as young programmers, it is a very good habit to have a small book, where u can write very important codes for future use ... also note: if you only read this tutorial without practising it yourself , then your bound to forget... as programmers, you must practise what you learn... it will sink into your memory.. thank you. having these apparatus in place, let's proceed.... solution... // let's introduce suitable header files below...Part 1 1 #include <iostream> 2 #include <cstdio> 3 #include <math.h> // let's start program flow, declaring main...Part 2 4. using namespace std ; 5. int main () 6. { // we have declared the start of program flow, its //time to declared all our variables.... Part 3 7. double F ; // output force 8. double Q1 ; // input first charge 9. double Q2; // input second charge 10. double R ; // Input distance // lets declare the constanst K.. Part 4. 11. double K = 9000000000; // this valve will remain permanent... remember its a constant.. // Part 5 .. lets ask the user some questions 12. cout << " What is the valve of the first charge ( in columbs) : " ; 13. cin >> Q1; 14. cout << " What is the valve of the second charge ( in columbs) : " ; 15. cin >> Q2; 16. cout << "What is the valve of the distance ( in meters) : " ; 17. cin >> R; // Let's break it first into numrator..Part 6. 18. double numurator ; // variable for the numerator 19. numurator = ( Q1 * Q2 * K) ; // your done with this aspect.. move now to denominator. // Let's break the other part... denominator .. part 7... 20. double denominator ; // variable for lower part of formula.. 21. denominator = ( R * R) ; // your done with this aspect.. // part 8... lets compile part 6 and 7... 22. F = ( numurator) / ( denominator) ; // vola.. that's your force.. // finally, part 9.. produce results.. 23. cout << " From the given information provided by you, the force of attraction between two bodies is : "; 24. cout << " Force is equal to : " ; 25. cout << F ; 26. cout << " unit is in ( Newton) " ; // sign out... 27. system ( "PAUSE" ; 28. return 0; } 2 Likes 3 Shares |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:06pm On Oct 14, 2014 |
haxorDelite: yes it can, but its not suitable for this kind of tasks.. most common tools are java.. php.. but c++ , not dat in use.. |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:14pm On Oct 14, 2014 |
Ezechinwa: I implore you to test this codes... i will explain where neccesary... thank you. |
Re: C++ Tutorial For Beginners... Part 1... by swscorpio: 9:28pm On Oct 14, 2014 |
Ezechinwa: Noted.i will do that soon and give u a result.Tnx Man! |
Re: C++ Tutorial For Beginners... Part 1... by swscorpio: 9:35pm On Oct 14, 2014 |
Please bro,which type of programming language use a word " echo " whenever we want it to display that output,i use to c it on Linux programs.Tnx |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:39pm On Oct 14, 2014 |
swscorpio: its used for php.... bro... 2 Likes 1 Share |
Re: C++ Tutorial For Beginners... Part 1... by haxorDelite(m): 10:35pm On Oct 14, 2014 |
Ezechinwa:owk thank you |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 11:05pm On Oct 14, 2014 |
haxorDelite: ur welcome my brother... |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 11:06pm On Oct 14, 2014 |
GUYS PLS COME UP WITH A PROBLEM, LETS BREAK IT DOWN TOGETHER..... 3 Likes 1 Share |
Re: C++ Tutorial For Beginners... Part 1... by zyzxx(m): 8:20am On Oct 15, 2014 |
U rock bro |
Re: C++ Tutorial For Beginners... Part 1... by swscorpio: 8:36am On Oct 15, 2014 |
Ezechinwa: Hi bro,Pls is that possible to write a program that will detect every person that login to my system(Redhat 6)? |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:53am On Oct 15, 2014 |
swscorpio: Its very possible, most websites use such facility, for example gmail, Facebook... Etc ( user authenticity) ,,, I will make more research and share whatever I find... By d way, did you try out the second example?... 1 Like |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:55am On Oct 15, 2014 |
Re: C++ Tutorial For Beginners... Part 1... by zyzxx(m): 10:39am On Oct 15, 2014 |
Ezechinwa:not yet sir. But i will very soon 1 Like |
Re: C++ Tutorial For Beginners... Part 1... by swscorpio: 3:43pm On Oct 15, 2014 |
Ezechinwa: Yeah i tried it bro, it works fine it will display me a black dialog box asking: what is the value of the first charge < in columbs> what is the value of the second charge < in columbs> what is the value of the distance < in meters > And i do inserted the values, but i couldn't see the final answer that is the value of force(F) in Newton. |
Re: C++ Tutorial For Beginners... Part 1... by swscorpio: 4:00pm On Oct 15, 2014 |
Ezechinwa: On the above example; I run it and it work so well,this is the one i run;i just add some little thing,cos it give me errors before adding the first 2 line and the last one: int main () { // program that adds two numbers int a; // first number int b; // second number int c; // variable rep output c= a+b; // output of sum off two numbers } |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 11:01pm On Oct 15, 2014 |
wow.. over 400 views.. i think we are making a huge progress... well , you have seen just a little stuff of what cpp is made off... ( lol, am made of black sha)... we have been able to solve few examples... precisely 2... as i promised earlier, i can't show you everything about this amazing program, am just working on the basics.. .. i think we can move further from here... once again, thnks for the sharing, comments, replies.. etc... i will take a break for today , the next session will be on ... " Conditional statements in Cpp".... stay tuned... 3 Likes |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 11:04pm On Oct 15, 2014 |
pls, drop more comments, and ask more questions... let's build Nigeria together, or aren't we programmers?? 1 Like |
Re: C++ Tutorial For Beginners... Part 1... by haxorDelite(m): 7:01am On Oct 16, 2014 |
Bro can we combine javascript with it, for example => after inserting something in a field it opens automatically before one press opens |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 11:49am On Oct 16, 2014 |
haxorDelite: Yes sir... U can combine javascript with cpp... Take a look at the Link below for a better Explanation : http://www.codeproject.com/Articles/2352/JavaScript-call-from-C |
Re: C++ Tutorial For Beginners... Part 1... by picasso4u(m): 12:22pm On Oct 17, 2014 |
Ezechinwa:Ezechinwa, u re really doing a good job here. keep it up and God will increase ur knowledge. what is d function of d quotation mark(" b4 d directive |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 1:01pm On Oct 17, 2014 |
picasso4u: thnks bro... that wasn't part of the program, it was just an illustration of what the header files can do.. |
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 1:24pm On Oct 17, 2014 |
hello great minds... we are back again , what you saw in my previous posts were programs that can't make decisions... so, later on today, i will show you how to develop programs that can make decision... i haven't used variable types like boolean & string... so far, i will find problems needing such in future.... so later tonight... we move futher, for now i don't think my boss will find it funny seeing me posting rather dan working.. lol.. so, later guys... 1 Like 1 Share |
Re: C++ Tutorial For Beginners... Part 1... by picasso4u(m): 3:41pm On Oct 17, 2014 |
Ezechinwa:u are really a life saver bro. I comment only when I see d need to. I have really seen d need in did thread. thumps up 3 Likes 2 Shares |
(1) (2) (3) (4) (5) (6) (Reply)
Pros And Cons Of Dating A Programmer Or Just A Geek / How Much Do Web Developers Earn In Nigeria? / I Just Bombed A Technical Interview
(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. 80 |