DataTypes.cpp

I need to format the code with the correct indentation and descriptions. I have posted the code i have editied… please advise if further corrections are needed?

Problem

View the code in the Guessing Game.cpp file. Although the program compiles and runs, you will notice how difficult it is to read the code itself. An important part of programming is making your code readable so other developers can read and maintain it. Using these style guidelines, format and submit this code. 

Continue to follow these guidelines as you develop code during this course. 

this assignment, review the Formatting Assignment Guidelines and Rubric document.

*/

#include “stdafx.h”

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

int main()

{

//random number generator

srand(time(0)); 

//Seed the random number generator

int selectedNumber = rand()%20+1;int numberOfTries = 0;int inputtedGuess;

cout << “Guess My Number Gamenn”;

//Ask the user for a value until the correct number is entered

do

{

cout << “Enter a guess between 1 and 20:”; 

cin >> inputtedGuess;

++numberOfTries;

if(inputtedGuess>20 || inputtedGuess<1) {cout << “Your guess is out of range. nn”;}

else if (inputtedGuess > selectedNumber){cout << “Too high!nn”;}

else if (inputtedGuess < selectedNumber){cout << “Too low!nn”;}

while (inputtedGuess != selectedNumber);

//Congratulate the user and end the program

cout << “nCongratulations! You solved it in ” << numberOfTries << ” tries!n”;

return 0;

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp