- 1
Some pliz write me a simple program to find the Area and circumference of a circle given that radius is 4 and Pi is 22.7
22 odpowiedzi
+ 2
SoloLearn is not a code writing service. If you want to write the code, we can help you.
+ 2
Rather you mean to use Pi = 22.0/7.0, which is a common approximation.
Write one function that receives radius and returns 2*Pi*radius.
Write another that receives radius also and returns Pi*radius*radius.
Show here what you tried, and we'll help you if you need further assistance.
+ 2
The operator, ^, is a Bitwise Exclusive Or. There is no operator for exponent in C. The simplest way to square a number in C is to multiply it.
float area = PI*radius*radius;
+ 1
pi is 22.7 ???
the formula to get an area of a circle is pi * radius ^ 2
the circumference is 2 * pi * radius
pi is supposed to be 3.14159. it cannot be changed.
+ 1
alright, when asking a question on any online forum, you have to do some work yourself and never expect others to write code for you. I asked "what have you tried" and you are not giving any code!
put in as much information as you can in your question so we can know where the problem is...
writing a formula for an area and circumference is very basic. We want to know if you are having trouble getting user input, or if there are compilation errors. Maybe you do have some code but it does not give the right answer.
give us something so we can help you.
+ 1
#include<stdio.h>
int main () {
// data type identifier;
int radi ;
int PI ;
// calculate area of a circle ;
radi= 40 ;
PI= 3.1428 ;
int area= PI * radi ^2 / 2;
printf ("area:%d \n" , area) ;
return 0;
+ 1
ok thank you for giving some code. I have some reviews for you:
you should rename radi to radius. the radius should be a float type.
float radius;
PI needs to be a float of value 3.14159
float PI = 3.14159;
you didn't read my answer that mentions the formula to use for the area of a circle.
it should also be a float type.
float area = PI * radius ^ 2;
your are missing the closing curly braces } after return 0;
---
I hope this helps, but you should understand that asking a good question is important. ALWAYS add details, otherwise no one will be able to help. in your case you had syntax errors, along math errors. The original question made it impossible to know these were the problem.
+ 1
Blaq Mosh For a new question, open a new post
0
what have you tried? what language do you need help with?
0
C
0
Thanks let me try
0
Once I put the float ...and run the program, it shows an error on the word float and says it turns to binary
0
Did it as well still errors
0
Blaq Mosh if you changed the variable type for area from int to float, then the print format specifier also must match. Change %d to %f.
print("area: %f\n", area);
Keep at it. Teach the computer who is the boss!
0
🤣🤣🤣 let me see
0
Brian ur right man 🥰 drop ur number we connect not only here bt on whatsapp too...please
0
It worked??
0
Blaq Mosh, Sololearn is the only social media where I can be found.
There is a great community of patient experts and helpers here. Feel free to post more questions, and remember first to show what you tried - even if it doesn't work.
0
How can we write program to calculate percentages of 5 subjects
0
Thank u sir