473,322 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to calculate diameter, circumference and area of a circle by using radius

How to calculate diameter, circumference and area of a circle by using radius---

Hello!
I have been trying to learn C language.I bought a book "C How to Program,Deitel&Deitel"...I make practise by myself,but sometime it get harder for me...i searched good examples on the internet.i have two example of four,which i couldnt do.these are;
1) Write a program that declares 2 floating point numbers and initializes them to 1.5 and 5.5 respectively. Find the multiplication and sum of both those numbers and print the results on screen.
2)Write a program that enters the radius of a circle and prints the circle’s diameter, circumference and area. Perform each of these calculations inside the printf statements.

Somebody help me?I think,i did everything what i must to do..but is doesnt work =(
Oct 11 '07 #1
9 22425
Meetee
931 Expert Mod 512MB
How to calculate diameter, circumference and area of a circle by using radius---

Hello!
I have been trying to learn C language.I bought a book "C How to Program,Deitel&Deitel"...I make practise by myself,but sometime it get harder for me...i searched good examples on the internet.i have two example of four,which i couldnt do.these are;
1) Write a program that declares 2 floating point numbers and initializes them to 1.5 and 5.5 respectively. Find the multiplication and sum of both those numbers and print the results on screen.
2)Write a program that enters the radius of a circle and prints the circle’s diameter, circumference and area. Perform each of these calculations inside the printf statements.

Somebody help me?I think,i did everything what i must to do..but is doesnt work =(
Hi,

What difficulties you are encountering? Please post your efforts here. There are some formulas of circle. You just need to apply them in C. everything is given here so describe your exact problem.

Regards

PS Read posting guidelines
Oct 11 '07 #2
I have nothing about the first question...but i made something for the second one..

"
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3. int main()
  4.  
  5. {
  6.     int pi,radius,diameter,circumference,area;
  7.  
  8.     printf("Enter the radius of the circle\n");
  9.     scanf("%d",&radius);
  10.  
  11.     pi=3,14;
  12.     diameter=radius*2;
  13.     circumference=2*pi*radius;
  14.     area=pi*radius*radius;
  15.  
  16.     scanf("%d%d%d",&diameter,&circumference,&area);
  17.  
  18.     return 0;
  19. }
"
Oct 11 '07 #3
kreagan
153 100+
I have nothing about the first question...but i made something for the second one..

"
Do you not understand the question? (Quite honestly, I think the second question was trickier than the first.) Why is the first question giving you problems?
Oct 11 '07 #4
The first one is too easy.
The second one maybe something like this

[ spoonfeeding code removed ]
Oct 11 '07 #5
JosAH
11,448 Expert 8TB
int pi
There is some biblical 'evidence' (mind the quotes) that this should be true but
the entire mathematical world thinks otherwise.

kind regards,

Jos
Oct 11 '07 #6
Sorry for that, I am new and I just read the guidelines. This will not be repeated.
Oct 11 '07 #7
Do you not understand the question? (Quite honestly, I think the second question was trickier than the first.) Why is the first question giving you problems?
is this important which one is easier?these are my efforts.i tried to do something.but i cant...
Oct 11 '07 #8
Banfa
9,065 Expert Mod 8TB
is this important which one is easier?these are my efforts.i tried to do something.but i cant...
Actually it is important, because what you learn by doing question 1 you will use in solving question 2, which is probably why they were set in that order.
Oct 11 '07 #9
kreagan
153 100+
is this important which one is easier?these are my efforts.i tried to do something.but i cant...
The comment wasn't ment to undermind your efforts at all. I'm just confused why you are stuck since you did the second one with no help from this forum.

Maybe this might help you. The first problems uses the exact same principles as the second except changes what you are looking for. Instead of finding the area, you are creating a number that is the addition of the two given variables and a multiplication of the two.
Oct 11 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Talon | last post by:
Hi all, I am new to Tk, so please bear with me. I need someone better at math than me to help me figure this out. I am drawing multiple arcs on the same circle. All arcs start at 90 and have...
14
by: Pythor | last post by:
I wrote the following code for a personal project. I need a function that will plot a filled circle in a two dimensional array. I found Bresenham's algorithm, and produced this code. Please tell...
38
by: jdcrief | last post by:
Complier: Visual C++ 2005 Express Edition The program I wrote will compile and execute, but the output is always the same, no matter what number is entered in for the radius of the circle. ...
2
by: wrestling god | last post by:
Hey everyone, kinda struggling with a part of my hw assignment. would anyone know how I could get started.?? here is the question: Graphical Determination of Pi: The full value of pi, which no...
7
by: heterodon7 | last post by:
hello, can anyone give me a clue or simple code on task: for example we have in 2D an equation fo circle: (x - 3)^2 + (y - 4)^2 = 25. now the program must return for example a 40 pairs of...
1
by: ccaddiso | last post by:
I want to retrieve my x1, x2, y1, and y2 from a text file using getline, but i don't know how. const double PI = 2.0 * asin(1.0); // class declaration class Point { protected:
1
by: tiffrobe | last post by:
I'm a little lost on my program. Everything works fine except function 3. It gives out garbage numbers. Its suppose to give the distance between two points and then the area of 2 circles. ...
26
by: Prime Mover | last post by:
Hello all, I have got the pseudo-code below that I would like to convert to c language. The algorithm calculates Pi value. I am somewhat familiar with C language, but I am just starting to learn...
1
by: cmwb2000 | last post by:
Hi I am trying to calculate the radius of a circle of best fit from 2 or 3 mouse positions. At present I am recording a series of points a mouse passes, I intended to pick the first and last point...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.