Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,972 members, 7,806,824 topics. Date: Wednesday, 24 April 2024 at 02:33 AM

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. (459 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)

(1) (Reply) (Go Down)

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'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?

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:

I guess you are a futo student?
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:
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).
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:

I guess you are a futo student?
#Mautech
Re: Please What Is The Logic Behind This Program (C++), I'm Bored. by Scout60(m): 8:11am On Jun 25, 2020
jpawjpaw:
Nop, why did u say so?
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:


Because of the course code....
are you learning c++ to know or just pass your exams?

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:


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.

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:


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++
wow thanks for the idea, I really appreciate.

I will do as you said.

(1) (Reply)

I Was Not Shortlisted / Top 10 Most Educated African Presidents Ever / Lagos Set To Reopen Schools August 3rd

(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. 18
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.