C/C++ :: Calculate Radius Of Cylindrical Rod In Inches
Feb 14, 2014
Exerted by the rider's foot yet not exceed the stress placed on the crank arm's sprocket attachment, is provided by this formua:
r^3 = d*p/s*π
r is the radius of the cylindrical rod in inches. d is the length of the crank arm in inches. P is the weight placed on the pedal in lbs. S is the stress in lbs/in2
Using this information, design, write, compile, and execute a C++ program that computes the value of r for a crank arm that is 7 inches long, accommodates a maximum weight of 300 lbs, and is able to sustain a stress of 10,000 lbs/in2.
View 1 Replies
ADVERTISEMENT
Apr 4, 2015
This program must take user input(from stdin) that contains both a number and then a punctuation character, either a single quote(') or double quote(") that specifies feet or inches. It keeps prompting the user to enter a length until the user enters the sentinel value of 0. For example:
Enter a measurement and unit: 1'
Enter a measurement and unit: 2"
Enter a measurement and unit: 0
Total: 14 inches
The ultimate goal of this program is to then write an Assembly language program that is structurally similar and makes use of these 4 functions:
void printStr(char *)
Arguments:
edi = address of null-terminated string to print
Returns:
Nothing
[Code] ...
So here is what I have:
int main() {
char value[50];
char *end;
int sum = 0;
long conv;
while(conv !=0)
[Code] .....
I was told to use fgets instead of scanf for for stdin to parse the number and the quotation marks. I think I converted the number from string to integer correctly with strtol, but I really do not know how to obtain the (") or (') from user input so the program knows whether to convert the number to feet or just inches. No matter what I type in, even if it's without a quotation mark, it still multiplies the number by 12. In the IF and ELSE IF statement, it should state
if(value = ''')
and...
else if(value = '"')
View 4 Replies
View Related
Jul 25, 2014
I was given an assignment to enter two sets of numbers for yards, feet, and inches, and then add them together and convert it to inches. That part of the program is correct, but now I need to calculate the area. It is a working program, but my final answer is in inches, and it is supposed to be in yards, feet, and inches. How do I convert the calculated inches back to yards, feet, and inches?
Code: typedef struct {
int yards;
int feet;
float inches;
} yardfeetinches;
typedef struct {
[Code] ....
View 2 Replies
View Related
Apr 28, 2012
How can i come up with a program that uses entered radius of a circle to find its area
View 1 Replies
View Related
Jun 22, 2013
Any class or library that can to calculate the center and radius of a sphere from 4 known points on its surface?
View 9 Replies
View Related
Apr 10, 2013
I'm getting a error on my Circle::Circle(double radiusValue) constructor. My instructions is 'Add a constructor that accepts one argument and uses it to set the radius.'
#include <iostream>
#include <cmath>
using namespace std;
class Circle {
private:
double x;
double y;
double radius;
[Code] .....
View 3 Replies
View Related
Jan 22, 2014
I am drawing a circle using ellipse because there is no explicit command for this.
Code:
pDC->Ellipse(CRect(70, 170, 300, 400));
What is the centre of circle and what is radius in the above command?
View 2 Replies
View Related
Jan 23, 2014
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;
[Code] ...
View 5 Replies
View Related
Oct 7, 2013
Let (x,y) be the center of the circle. (x,y) will not be (0,0). I have radius of the circle. Now i want to find the angle and radius of the given point inside the circle.
View 2 Replies
View Related
Sep 16, 2013
Write a program to convert a measurement in centimeters to inches. The numbers of centimeters should be read as input. Define int variable for centimeters, inches, and feet. Convert the centimeters to inches, then convert the inches to feet and inches (use the % operator). Print the distance in all three units. There are 2.54 centimeters in each inch and 12 inches in each foot.
View 3 Replies
View Related
Oct 21, 2014
I have my program all but done, but I can't get past this last part. I need to have the user input their height as a decimal. For example someone who is 5 foot 11 inches would need to enter it as 5.11, then I need to display there height in inches. Since i'm 5 foot 11, I would need to enter 5.11, then have it display 71 inches.
View 4 Replies
View Related
Jan 14, 2015
I need to write this program (shown below) for class but i'm not sure how to print out a table?
Write a program to display a centimeters-to-inches conversion table. The smallest and largest numbers of centimeters in the table are input values from the user. Your table should give conversions in 10-centimeter intervals. One centimeter equals 0.3937 inches.
Here is my code so far
Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
[Code].....
View 6 Replies
View Related
May 9, 2013
I am new to c++, and I have been going through some basic code to get used to the syntax etc. I have encountered a compiling issue with my current code. The purpose of this code is to convert feet and inches into meters and centimeters.
#include <iostream>
#include <cmath>
using namespace std;
int main () {
<<<xcode is saying I have an expected expression on this blank line>>>
double feet1, inch1, inch2, meter1, centimeter1;
cout << "Please enter a length in feet and inches " << endl;
cin >> feet1 >> inch1 >> ;
I have tried rewriting the #include through int main () expressions, I've tried copy/pasting the lines from other pieces of code...
View 5 Replies
View Related
Jul 14, 2013
I have to write a code to convert centimeters to yards feet and inches i have the code wrtten up and keep getting 2 errors saying im missing a ; before << but im not sure why ?
#include <iostream>//For cin and cout
using namespace std;
int main(void) {
doublecentimeters; //INPUT
[Code] ....
View 2 Replies
View Related
Oct 22, 2012
I am attempting to write a simple C program, in which the user is asked to input their name and height in inches and the output is the user's height in centimeters.
I have attached my program and what happens when I try to run it.
Attached Images : PM.jpg (120.6 KB)
View 1 Replies
View Related
Feb 3, 2014
I am facing a programming logic problem. I want to draw radius sized lines from centre of circle to the circle boundary.
My code is:
int x1, y1, x2, y2, i, r, old_xc,old_yc, x,y;
int xc, yc;
x1=170;
y1=300;
x2=70;
y2=400;
pDC->Ellipse(x1,y1,x2,y2);
[Code] .....
The lines are touching the circle boudary at only start while the rest of lines are smaller and the shape is a triangle instead of a pie slice.
View 8 Replies
View Related
Jul 12, 2013
I'm trying to write a program to calculate an approximate value of e using the formula e = 1 + 1/1! + 1/2! + ....... 1/n!...However, I'm always getting nearly 2.291481 as answer.Here is my code :
Code:
//Approximate the value of e
#include <stdio.h>
int main(void) {
int n, j;
printf("Please enter value of n : ");
scanf("%d", &n);
[code]....
I know I'm not supposed to use system("PAUSE"), but this is self-study.
View 8 Replies
View Related
Oct 7, 2013
I'm trying to successfully run a program that calculates your BMI but, although it runs, it is not giving the the correct math. Instead, it gives me the number i've submitted as my weight as an answer. I'm using Visual Studio 2008 and the formula: weight / (height/100)*2
Here is my code
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int weight;
int height;
double BMI;
[Code] ....
View 2 Replies
View Related
Jan 1, 2013
Let's say I want to calculate something like PI using some algorithm, but with the number of digits I want to.
View 1 Replies
View Related
Nov 22, 2014
I want calculate sum of every digit in my zip code so I wrote implementation function like that but, it shows "0" as answers, then I realize it should be call first, I add correctionDigitOf() in to constructor "Zipcode::Zipcode" then My zipcode are all "0' after I do this .....
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <ctime>
#include <cmath>
using namespace std;
class Zipcode {
[Code] ....
View 1 Replies
View Related
Aug 7, 2012
Contributions won't calculate ...
#include <stdio.h>
#include <conio.h>
int main() {
float tax;
float salary;
float taxable;
float taxmo;
float contributions;
[Code] .....
View 1 Replies
View Related
Mar 22, 2013
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 ()
[Code] .....
View 7 Replies
View Related
Feb 20, 2014
My question is not in c++ programing , but because my aim is to make code that calculate the three angles between two vector i ask my question here
So as the title i have three point that create two vector and I want to get the angles in x,y and z of the point2
I used crosproduct that give me one angle without axe , I don't know in which axe this angle
My aim is the three angles for the 3 axes ....
View 7 Replies
View Related
Aug 3, 2014
Now I know there's a simple way to calculate highest value. But here i have this algorithm which i understood part of it.
I know that *largest is point to the first element of begin which is 5. so in the first if statement its 5<5 at the first iteration ?
// i marked the parts i didnt understand with " //"
Code:
#include <stdio.h>
int *print(int *begin ,int *end ){
if(begin==end)
return 0;
int *largest = begin;
[Code] ....
View 10 Replies
View Related
May 23, 2013
I have to calculate the value of PI with the accuracy (eps) given by the user. I started with this but I just got stuck now, I don't know what is going on with the code or why does it get stuck in the second iteration...
PHP Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
float eps=0.000001;
[Code] ....
View 4 Replies
View Related
Nov 23, 2013
What the range of values and how to calculate them?
int Num = rand() % 350 + 13 / 10
View 2 Replies
View Related