Please What Is The Logic Behind This Program (C++), I'm Bored. - Education - Nairaland
Nairaland Forum › Nairaland General › Education › Please What Is The Logic Behind This Program (C++), I'm Bored. (675 Views)
| Please What Is The Logic Behind This Program (C++), I'm Bored. by jpawjpaw(op): 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(op): 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(op): 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(op): 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(op): 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++ |
| Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by jpawjpaw(op): 11:28am On Jun 25, 2020 |
Scout60:wow thanks for the idea, I really appreciate. I will do as you said. |
The Logic Of Writing • Logic Behind Best Placement Offers At T. A. Pai Management Institute? • I Need A Detailed Explanation To This Funny But Real Logic Question. • 2 • 3 • 4
Scholarship And Admission: Is This Real??? • Scholarship; Federal Government Scholarship Award 2021/2022 Ongoing. Apply N • Why We Haven’t Called Off Strike –ASUU