Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,783 members, 7,955,995 topics. Date: Sunday, 22 September 2024 at 08:49 PM |
Nairaland Forum / Nairaland / General / Education / Please What Is The Logic Behind This Program (C++), I'm Bored. (526 Views)
The Logic Of Writing / Logic Behind Best Placement Offers At T. A. Pai Management Institute? / Crack The Logic If You're Smart Enough (2) (3) (4)
Please What Is The Logic Behind This Program (C++), I'm Bored. by jpawjpaw(m): 2:03pm On Jun 24, 2020 |
I'm a beginner in C++, we were just starting the course (CSC 201) before oga Corona sent us back home. Incase you have knowledge in C++, I need your help please. Is this a logic error, or the C++ was designed that way; sin 30 = 0.5 normally, but here in my program, I'm getting -0.98803(negative number), same goes with sin 60. Here is the program below, incase u have an idea, please help a brother. #include <iostream> #include <cmath> using namespace std; int main ( ) { double x = 30.0; double y = 2.0; cout << sin (x) <<endl; cout << x/y <<endl; // I want the program to print 0.5 and 15. // but I'm getting something else. return 0; } so please what could be the problem? |
Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by Davechuks360(m): 7:26pm On Jun 24, 2020 |
Sin and Cos functions take the angle parameter in radian. You should convert the angle to radian first before passing into the sin/cos function. I don't really know c++, but in Java, you'll use Math.toRadian(angle in degree). |
Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by clockwisereport: 8:33pm On Jun 24, 2020 |
. |
Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by Scout60(m): 10:35pm On Jun 24, 2020 |
jpawjpaw: I guess you are a futo student? |
Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by jpawjpaw(m): 10:43pm On Jun 24, 2020 |
Scout60:Nop, why did u say so? |
Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by jpawjpaw(m): 11:22pm On Jun 24, 2020 |
Davechuks360:okay sir, thank u. |
Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by jpawjpaw(m): 11:24pm On Jun 24, 2020 |
Scout60:#Mautech |
Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by Scout60(m): 8:11am On Jun 25, 2020 |
jpawjpaw:Because of the course code.... are you learning c++ to know or just pass your exams? |
Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by jpawjpaw(m): 9:35am On Jun 25, 2020 |
Scout60: Oooh, ok........ I'm learning to know oo, not just pass my exams; learning to just pass exams is not the way out. I have done that in my 100L, and then it was Java, I crammed to pass, and now I've forgot almost everything in Java; so I can't afford to repeat that in c++. I want to become a guru in it. |
Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by Scout60(m): 11:01am On Jun 25, 2020 |
jpawjpaw: Java and c++ is always complex for beginners. If you want to become in c++ then find a personal tutor that will guide you but if you want to learn on your own, I suggest you start with python which is beginner- friendly. With python, u will understand how programming works and you will put the ideas towards learning c++ 1 Like |
Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by jpawjpaw(m): 11:28am On Jun 25, 2020 |
Scout60:wow thanks for the idea, I really appreciate. I will do as you said. |
(1) (Reply)
. / Earn Over #150,000 Monthly By Simply Teaching English Online To Foreign Students / Sure And Fast Way To Secure Admission, Scholarship Abroad
(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. 17 |