I was given an assignment for class to calculate the area of a circle using only the radius as a user input and not using Pi in the code. I need to do this by calculating the areas of a series of rectangles under the curve and adding them together. Using nested loops to continuously reduce the size of these rectangles until the approximated area value is within a margin of error less than 0.1%.
Code: #include<iostream> #include<cmath> using namespace std; int main ()
Below is what i have so far. My main issue is outputting the area and perimeter of the given coordinates as i need the final coordinate to connect up to the first coordinate. I've tried doing that using numberOfcorners but it says "the expression must have integral or enum type"
#define _USE_MATH_DEFINES #include <iostream> #include <cmath> #include <math.h> using namespace std; int main() {
What I'm trying to do is create a dividend calculator that loops through each quarter printing the quarter # as done, then what I want it to do is loop through the calculations at the end.
double compute_taxes(double gpay) { double gross; double td; // to hold the tax deduction if (gross <= 1000) td = gross * 0.5; else if(gross < 1500) td= gross * 0.6;
[Code] ....
Write the function double compute_npay(double gpay) that receives an employee's gross pay using the value parameter gpay, computes the net pay and returns it. the net pay is the gross pay - the tax deduction. To compute the net pay, it first calls compute_taxes() to compute the tax deduction.
What is wrong with this code cause im not getting the correct ratio of total people to cumulative length?
Code: #include<stdio.h> #include<stdlib.h> //define constant variables #define FIRST_CAR_LENGTH 10 #define NORMAL_CAR_LENGTH 8 #define CAR_CAPACITY 4 int main(void){ //Set up some variable with values that come from input or calculations
#include <stdio.h> #include <stdlib.h> int b_diff (int, int);
[Code].....
I am trying to take two arrays H[], and V[] and call each element to compute the bit difference(Hamming distance) and return that back to the main function to be used in calculating pixel_phase and pixel_smoothing. I'm getting an error that bit_diff cannot be used as a function and I've tried renaming it but nothing seems to work.
[ int b_diff (int a, int ] is how it should actually look.int b_diff (int a, int is how it should actually look).
I'm suppose to provide an inner loop that computes the zeta function and the other loop is just press y for to continue, anything else exit.so far i got this:
#include <iostream> #include <cmath> #include <stdlib.h> using namespace std; int main() { double x, n,zeta;
RecursiveComputeRouteDistance(p1index,p2index,locations,latitudes,longitudes): recursively computes the total distance between all waypoints (route) using computeDistance function to compute the distance between two adjacent points. You need to recursively compute the distance for the base case(s) and the general case(s).
I made a simple program to compute the lengths of a triangles sides, but when I enter 30 for angle and 10 for hypotenuse I get the opposite side is -9.880316 and the adjacent is 1.542514.
i am looking for a verified code in simple c, for generating fft of an input image (.jpg). the output can be a text file including fft coefficients.can you recommend me any source except open-cv?
I'm supposed to print a small rectangle inside concentric circles that are inscribed in a rectangle.I'm not really sure where to start with printing a circle in a ppm file.
Found a good beginner's tutorial to learn Visual C++: [URL] ....
How to change the drawing so that instead of squares, the game draws circles. Can figure out that using Ellipse in the code results in circle outlines, but the fill remains as square color shapes.
The drawing code from the tutorial is below. How to substitute filled circles for filled squares.
Code:
// CSameGameView drawing void CSameGameView::OnDraw(CDC* pDC){ // First get a pointer to the document CSameGameDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if(!pDoc)
#ifndef CIRCLE_H #define CIRCLE_H class Circle { public: //constructors Circle(); Circle(double r);
[code]....
The function isBigger() returns true (or false) if the radius of the Circle instance on which the function is invoked is bigger (or smaller) than the radius of the Circle instance passed to the function.: How to implement this function?
Im supposed to create an to array of eight Circle objects initialized with the following radii: 2.5, 4.0, 1.0, 3.0, 6.0, 5.5, 3.5, 2.0. Then use a bubble sort to arrange the objects in ascending order of radius size before displaying the area of each object.
The error I get is "Cannot open include file: 'Circle.h': No such file or directory". Do I have to create a separate file for it?
#include <iostream> #include <iomanip> #include "Circle.h" using namespace std; class Circle { public: Circle()
I installed FLTK 1.3.X (from here [URL] ...) on my visual studio 2012 compiler and use PPP book for programming (this: [URL] ..... ). My problem is about filling a Shape in. For example , this code:
#include <Simple_window.h> using namespace Graph_lib; int main() { Simple_window win(Point(100,100), 1000, 600, "Binary_tree"); Graph_lib::Circle c(Point(200,200),50); c.set_color(Color::red);
[Code] ....
When I run the program, All three Shapes are drawn but only the Rectangle is filled in! Why?
set_color works for the three and apparently the set_fill_color is defined for all Shapes and it too should work but why it doesn't work for Circle and Ellipse?
I'm trying to create a PPM image for a class assignment. A black rectangle with a circle at the point 225, 175 with a radius of 75. I have to use certain specific methods, so I can't use like Bresenham's really famous method for creating a circle.
The problem is that it compiles fine, and transfers to an image fine, but always says that I have a negative or zero image size.
I am working on a computer program where I need to generate points on a circle. I am familiar with this kind of algorithm:
for(d=0; d<=2*pi; d+=0.01) { x = cos(d)*radius; y = sin(d)*radius; }
However, due to the specifics of the program I am writing, I need to iterate through a fixed number of points one at a time, like so:
for ( int x = 0; x < blockSize; x++ ) { y = ??? }
This essentially "fixes" one axis of the circle, since I can't do: x=rx+sin(d)*r.
I have tried simply: "y = sin(d)*radius;" and I get a curved shape, but it's not a circle.
My question then is, how do I get the value of y in this situation, where the x axis is incrementing by 1 through a range of values? Is it mathematically possible?
My problem is the following : We have a circle paper of radius R. We will cut off a sector of this circle (with length rem_sec), and the remaining (bigger part) will create a cone. Radius of cone base is r.
I need to create a code that prompts the user to enter circle's radius R and the program will calculate the length of removed sector (rem_sec) so that the created cone has the Max Volume.
I wrote the following code, but it doesn't work. It displays both rem_sec and MaxV = 0.
#include <iostream> #include <cmath> #include <iomanip> #include <conio.h> using namespace std; const double PI = 3.1415; int main() { double rem_sec;