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

5. points Look at the folowing statements. char strti -237.83 value. double valu

ID: 3570201 • Letter: 5

Question

5. points Look at the folowing statements. char strti -237.83 value. double value: to a double and stores the resultin Write a statement tatoomwertste stingin 5 points Look at the following function definition. void get Number (int en) f cout "Enter a number: cin n; is a pointer. reference variable. Rewrite the function so that n this function, the parameter n is a paralel 5 points Ina program you need tostore the populations of 12 countries. Define two arrays that may be used in s tostone the names of the countries and their populations. Write a loop that uses these arrays to print each country name and population. 8 points) wrte a function named getNumber tat uses a reference parameter variable to accept an integer argument. The functn should prompt the user to enter a number in the range of 1 through 100. The input should be validated and stored inthe parameter variable. points Comvetthe following for loop to a while loop: for (int z 50: 0: x--) cout x seconds to go. In"; 10. points) Convert the following teise istatement into a switch statement if (choice 1) setprecision (2); cout fixed showpoint else if (choice 2 II choice 3) cout k fixed howpoint setprecision (4) s else if (choice 4) cout fixed showpoint setprecision (6) cout fixed showpoint setprecision (8)

Explanation / Answer

5)

char str[] = "237.89";
double value;
value = strtod(str, NULL);

6)

void getNumber(int *n)
{
cout<<"Enter a number: ";
cin>>*n;
}

7)

#include<iostream>
using namespace std;

int main()
{  
     char countries[12][15] = {
     "india",
     "canada",
     "china",
     "malasia",
     "japan",
     "russia",
     "England",
     "USA",
     "Australia",
     "Mexico",
     "Bangladesh",
     "Sri lanka"
     };
  
     int population[12] = {120,13,140,5,26,37,14,3,15,16,37,12};
  
     for(int i=0; i<12; i++)
     {
          cout<<countries[i]<<" -->"<<population[i]<<" ";
     }
  
     return 0;
}

8)

#include<iostream>
using namespace std;

void getNumber(int &n)
{
     int i;
     cout<<"Enter a number between (1 - 100) : ";
     cin>>i;
  
     if(i >= 1 && i<= 100)
          n=i;
     else
          cout<<" Sorry, n should be between 1-100 only ";
}

int main()
{
     int n;
     getNumber(n);
  
     return 0;
}

9)

int x=50;
  
while(x>0)
{
     cout<<x<<" seconds to go. ";
     x--;
}

10)

switch(choice)
{
     case 1:
     cout<<fixed<<showpoint<<setprecision(2);
     break;
  
     case 2:
     cout<<fixed<<showpoint<<setprecision(4);
     break;
  
     case 3:
     cout<<fixed<<showpoint<<setprecision(4);
     break;
  
     case 4:
     cout<<fixed<<showpoint<<setprecision(6);
     break;
  
     default:
     cout<<fixed<<showpoint<<setprecision(8);
     break;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote