Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ER 2, Exercise 2.12 (Ocean Levels) The Earth\'s ocean levels have risen an avera

ID: 3667931 • Letter: E

Question

ER 2, Exercise 2.12 (Ocean Levels) The Earth's ocean levels have risen an average of 1.8 millimeters per year over the p and displays the number of centimeters. One centimeter is equivalent to 0.3937 inches. The output of your ast century. Write a program that computes centimeters and number of inches the oceans rose during this time. One millimeter is equivalent to 0.1 program should be of this form: ocean rose X centimeters or Tinches in the last 100 years. where X and Y are the two numbers your program calculated. -140f 4: Sun Feb 14 2016 10:23:24-GMT-0800 (PST) B SUBMIT #include 2 using namespace std

Explanation / Answer


// header file
#include <iostream>

using namespace std;

int main(){
   // declare variables
   float risen = 1.8, centimeters = risen * .1,
   inches = centimeters * .3937;
  
   // display output
   cout << " The ocean rose " << centimeters << " centimeters per year";
   cout << " The ocean rose " << inches << " inches per year. ";

   return 0;
}

Output


                                                                                                                                                            
The ocean rose 0.18 centimeters per year                                                                                                                    
The ocean rose 0.070866 inches per year.                                                                                                                    
                    
Diamond triangle

// header files

#include <stdio.h>

int main()
{
int n, c, k, space = 1;

printf("Enter number of rows ");
scanf("%d", &n);

space = n - 1;

for (k = 1; k <= n; k++)
{
    for (c = 1; c <= space; c++)
      printf(" ");

    space--;

    for (c = 1; c <= 2*k-1; c++)
      printf("*");

    printf(" ");
}

space = 1;

for (k = 1; k <= n - 1; k++)
{
    for (c = 1; c <= space; c++)
      printf(" ");

    space++;

    for (c = 1 ; c <= 2*(n-k)-1; c++)
      printf("*");

    printf(" ");
}

return 0;
}

output
                                                                                                                                               
    *                                                                                                                                                       
   ***                                                                                                                                                      
*****                                                                                                                                                     
*******                                                                                                                                                    
*****                                                                                                                                                     
   ***                                                                                                                                                      
    *