1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
son4ous [18]
2 years ago
12

Write a program to get radius of circle and then print it's circumference​

Computers and Technology
1 answer:
s344n2d4d5 [400]2 years ago
8 0

\tt r=(int(input("Enter \:the\: value\: for \;radius:\:")))

\tt A=3.14*r**2

\tt C=2*3.14*r

\tt print("Area\:of\:the\:circle:",A)

\tt print ("Circumference\:of\:the\:circle:",C)

Output:-

\tt Enter\: the\:value\:for\: radius: 2

\tt Area\:of\:the\:Circle:12.56

\tt Circumference\:of\:the\:Circle:12.56

You might be interested in
Write a program that simulates flipping a coin repeatedly and continues until three consecutive heads. are tossed. At that point
quester [9]

Answer and Explanation:

#include <iostream>

#include <string>

#include <time.h>

#include <vector>

using namespace std;

//Takes user info

int user_info(string *name,char *gender){

   char G;

   cout<<"What is your name?: ";

   getline(cin, *name);

   cout<<"What is your gender(m/f):";

   cin>>G;

   cout<<endl;

   *gender = tolower(G);

   return 0;

}

//Toss coin(part 2)

bool coin_toss(double seed){

   double r;

   r = (double)seed/(double)RAND_MAX;

   //cout<<r;

   if (r<0.5) return true;

   return false;

}

//check results

float toss_result(vector<char> v,int *h){

   int num_heads=0;

   int num_toss = v.size();

   *h = 0;

   for(int i=0;i<num_toss;i++){

       if(v[i]=='h'){num_heads++;(*h)++;}

   }

   return (float)num_heads/(float)num_toss;

}

void show_result(int total_num,int head_num,float ratio){

   cout<<"it took you "<<total_num<<" tosses to get 3 heads in a row"<<endl;

   cout<<"on average you flipped heads "<<(ratio*100)<<"% of the time"<<endl;

}

int main()

{

   string name;

   char gender;

   string K; //Mr or Mrs

 

   cout<<"Welcome to coin toss! Get 3 heads in row to win!"<<endl;

 

   //part 1

   user_info(&name,&gender);

 

   if(gender == 'f') K = "Mrs.";

   else K = "Mr.";

 

   cout<<"Try to get 3 heads in a row. Good luck "<<K<<name<<"!"<<endl;

   char dummy = getchar();

 

   //part 2

   int num_toss;

   vector<char> toss_results;//store toss results

   bool result;//result of toss

   srand(time(0));

   while(true){

       //cout<<rand()<<endl;

       result = coin_toss(rand());

       cout<<"Press <enter> to flip"<<endl;

       while (1)

       {

           if ('\n' == getchar())

           break;

       }

     

 

     

       if(result) {toss_results.push_back('h');cout<<"HEAD"<<endl;}

       else {toss_results.push_back('t');cout<<"TAIL"<<endl;}

     

       num_toss = toss_results.size();

     

       if(num_toss>=3){

           if ((toss_results[num_toss-1] == 'h')&&(toss_results[num_toss-2] == 'h')&&(toss_results[num_toss-3] == 'h')){

               break;

           }

       }

   }

 

   //part 3

   float ratio_head;

   int num_of_heads;

   ratio_head = toss_result(toss_results,&num_of_heads);

 

   //part 4

 

   show_result(toss_results.size(),num_of_heads,ratio_head);

 

   return 0;

}

8 0
3 years ago
Lawanda starts a new job today at a company that delivers thousands of packages each day. Identify three ways in which Lawanda's
jek_recluse [69]

Answer:

use your own opinion

Explanation:

7 0
3 years ago
Write any four common hardware devices​
marishachu [46]

Answer:

Input devices: For raw data input.

Processing devices: To process raw data instructions into information.

Output devices: To disseminate data and information.

Storage devices: For data and information retention.

8 0
2 years ago
What might be some examples of Digital Citizenship Behavior?
likoan [24]

Answer:

Being nice to others and being respectful. Acting appropriately and with respect for you and others.

Explanation:

☆Hope this helps!☆

6 0
3 years ago
Find the simple interest Jay owes on a five-year student loan of $48,000 with an annual interest rate of 5%.
borishaifa [10]
Use the equation I=prt where interest = principal times rate times time.

Fill it out, it becomes I= 48000(.05)(5)

I= 12000
3 0
3 years ago
Other questions:
  • A company is utilizing servers, data storage, data backup, and software development platforms over an Internet connection.
    14·1 answer
  • How is a correction made to an Electronic health record?
    14·1 answer
  • What do economists call a decline in the real GDP combined with a temporary rise in price level?
    8·2 answers
  • What is the difference between electrical and electronic devices?
    5·2 answers
  • Someone please help ASAP will brainlist
    9·2 answers
  • What are foundations of any game systems that control what the players can or cannot do in the game, as well as the penalties, r
    8·1 answer
  • What is the different sheets in excel
    15·1 answer
  • How to square a number in java.
    15·1 answer
  • Why is a salt added to a password that is being stored in a database?
    5·1 answer
  • Lenny copied and pasted content from a commercial website into his research paper without citing his source, passing the work of
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!