Lab1 Solution
Lab1 Solution
S10
Lab 1
Sahil Purewal
100460278
#include <iostream>
#include <string>
int main()
{
string userName; //user's name
double examScore; //score obtained on exam
int examMax; //maximum score possible on
exam
double examPercentage; //percentage achieved on exam
cout << "Hi!, Type in your first name and press enter: " << endl;
cin >> userName;
cout << "What score did you get on the exam?" << endl;
cin >> examScore;
cout << "What was the exam out of?" << endl;
cin >> examMax;
system("pause");
return 0;
//end main
}
Lab 1B: Guessing game
//Program: Lab1B
//Programmer: Sahil Purewal CPSC 1103 Section: S10
//Purpose: Play a guessing game.
#include <iostream>
#include <cstdlib> //for random number generator
#include <ctime> //for time functions, random numbers
int main()
{
int number; // number of user to try to guess
int guessCount; // number of guesses the user has
made
int userGuess; // the user's guess
cout << "I picked a number between 1 and 100. Try to guess it!" << endl << endl;
cout << "You guessed right! It took you " << guessCount << "tries!" << endl;
cout << "By: Sahil Purewal CPSC 1103 Section: S10" << endl;
system("pause");
return 0;
// end main
}
Self reflection: