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
lorasvet [3.4K]
2 years ago
14

How do I fix when it hits the second session it skips scanf..

Computers and Technology
1 answer:
kozerog [31]2 years ago
4 0

Answer:

the answer can be found HERE:

https://stackoverflow.com/a/13473767

put a leading space in the scanf(" %c", &op)

Explanation:

#include <stdio.h>

#include <unistd.h>

#include <ctype.h>

main() {

double first, second;

char op;

while(1){

printf(" Calculator\n");

printf("\n 7 8 9 / \n 4 5 6 x \n 1 2 3 - \nEnter operator: ");

scanf(" %c", &op); //entering operators such as + - \ *

printf("Enter two operands:");

scanf("%lf %lf", &first, &second); //entering operands such as 1 2 5 8 12 414

switch (op) { // printing the math

case '+'://if its +

   printf("%.1lf + %.1lf = %lf\n\n", first, second, first + second);

   break;

case '-'://if its -

   printf("%.1lf - %.1lf = %lf\n\n", first, second, first - second);

   break;

case '*'://if its *

   printf("%.1lf * %.1lf = %lf\n\n", first, second, first * second);

   break;

case '/'://if its :

   printf("%.1lf / %.1lf = %lf\n\n", first, second, first / second);

   break;

default://if its not + - / *

   printf("error!");

}

}

}

You might be interested in
3 applications of cumulative probability distribution in medical field?​
kicyunya [14]

Answer:

The cumulative probability distribution can be used to find the total number of possibilities in the predecessor and the successor classes. Hence, suppose we want to find what is the probability of people having heart disease below 70 years of age, we can find through the cumulative probability distribution. Also, if we want to find the probability of various age groups having a coronavirus in the present day, we can find it through the cumulative probability distribution, or cumulative distribution function. Also, suppose we want to test medicine for the coronavirus by testing among the various age groups, the cumulative probability distribution as clear by definition is a must for such data analysis. Many more applications can be found. The cumulative probability means a certain value is less than or equal to a certain value, or fall below or above the mentioned limit.

Explanation:

Please check the answer section.

3 0
3 years ago
Write a calculator program that keeps track of a subtotal like real calculators do. Start by asking the user for an initial numb
Taya2010 [7]

Answer:

num1 = float(input("Enter the first number: "))

while True:

   print("Add, Subtract, Multiply, Divide, or Quit ?")

   choice = input("Your choice is: ")

   if choice == "Quit":

       break

   num2 = float(input("Enter the second number: "))

   if choice == "Add":

       num1 += + num2

       print("The subtotal is: " + str(num1))

   elif choice == "Subtract":

       num1 -= num2

       print("The subtotal is: " + str(num1))

   elif choice == "Multiply":

       num1 *= num2

       print("The subtotal is: " + str(num1))

   elif choice == "Divide":

       num1 /= num2

       print("The subtotal is: " + str(num1))

print("The final result is: " + str(num1))

Explanation:

Ask the user for the first number

Create a while loop that iterates until specified condition occurs inside the loop

Ask the user for the operation or quitting

If the user chooses quitting, stop the loop. Otherwise, get the second number, perform the operation and print the subtotal

When the loop is done, the user enters Quit, print the final value result

8 0
3 years ago
If you paste a word document text into an excel spreadsheet, the paste optio allow you to keep source formatting or
castortr0y [4]
I think the answer is c
6 0
3 years ago
Declare and initialize the following variables: int monthOfYear, initialized to the value 11 long companyRevenue, initialized to
lianna [129]

Answer:

Following are the declaration and the initialization of variable

int monthOfYear=11;  // variable declaration of integer

long companyRevenue=5666777; // variable declaration of long

int firstClassTicketPrice=6000;  // variable declaration of int

long totalPopulation=1222333; // variable declaration of long

Explanation:

Following are the description of Statement

  • Declare a variable " monthOfYear "  as integer type and initialized  11 to them .
  • Declare a variable " companyRevenue "  as long type and initialized  5666777 to them .
  • Declare a variable "  firstClassTicketPrice"  as integer type and initialized 6000 to them
  • Declare a variable " totalPopulation "  as Long type and initialized 1222333  to them .
4 0
3 years ago
Assume that speed = 10 and miles = 5. What is the value of each of the
Assoli18 [71]

a. speed + 12 - miles * 2  = 10 + 12 - 5 * 2. With order of operations, we do the multiplication first so the equation is now 10 + 12 - 10 = 22 - 10 = 12

b. speed + miles * 3  = 10 + 5 * 3 and again, order of operations gives us 10 + 15 = 25

c. (speed + miles) * 3  = (10 + 5) * 3 = 15 * 3 = 45

d. speed + speed * miles + miles  = 10 + 10 * 5 + 5 = 10 + 50 + 5 = 60 + 5 = 65

e. (10 – speed) + miles / miles = (10 - 10) + 5 / 5 = 0 + 5 / 5 = 5 / 5 = 1

5 0
4 years ago
Other questions:
  • Poems Roses are red,
    15·1 answer
  • One of the earliest uses of an electronic digital computer involved ________.
    8·1 answer
  • One of the main purposes of special effects is to accomplish shots that would be too expensive, too dangerous or just plain impo
    9·2 answers
  • Which of the following is the best subject line for an e-mail sent to co-workers about rescheduling a team meeting? A. Reschedul
    12·2 answers
  • Why is proper planning important?
    10·1 answer
  • How do design elements and color work together on a web page?
    15·1 answer
  • How does Accenture help companies harness the power of data to achieve optimal business outcomes?
    9·2 answers
  • Type the correct answer in the box. Spell all words correctly.
    12·2 answers
  • Data source contains addresses of the merge fields. true or false​
    8·1 answer
  • Complete the procedure for creating a contact group by selecting the correct term from each drop-down menu. 1. Click . 2. Enter
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!