Publicidad
Do While Loop Write a Do While loop that allows the user to enter floa.docx
Do While Loop Write a Do While loop that allows the user to enter floa.docx
Próximo SlideShare
Write a program using C language- (not C++!!) that can serve as a simp.docxWrite a program using C language- (not C++!!) that can serve as a simp.docx
Cargando en ... 3
1 de 2
Publicidad

Más contenido relacionado

Similar a Do While Loop Write a Do While loop that allows the user to enter floa.docx(20)

Más de wviola(20)

Publicidad

Último(20)

Do While Loop Write a Do While loop that allows the user to enter floa.docx

  1. Do While Loop Write a Do While loop that allows the user to enter floating point numbers greater than 0 and sums these numbers and prints the sum after the loop. The loop should exit after a number less than or equal to 0 is entered. Please do not add in values less than or equal to zero. Sample Output #1: Enter Positive Number to Add or Enter Zero or Negative Number to End: 99.0 Enter Positive Number to Add or Enter Zero or Negative Number to End: 67.5 Enter Positive Number to Add or Enter Zero or Negative Number to End: 0 Sum of Entered Numbers: 166.5 Solution #include int main() { double firstNumber, secondNumber, productOfTwoNumbers; printf("Enter two numbers: "); // Stores two floating point numbers in variable firstNumber and secondNumber respectively scanf("%lf %lf",&firstNumber, &secondNumber); // Performs multiplication and stores the result in variable productOfTwoNumbers productOfTwoNumbers = firstNumber * secondNumber; // Result up to 2 decimal point is displayed using %.2lf printf("Product = %.2lf", productofTwoNumbers); return 0; }
Publicidad