Skip to main content

Assignment B

Grade received: 100%

Problem B1

   This program demonstrates the close relationship between characters and numbers.
*/

#include<iostream>

using namespace std;

int main()
{
   char letter;
   int number;
   double decimalNumber;

   cout << "Enter a character: ";
   cin >> letter;
   number = letter;
   decimalNumber = number;
   cout << "Letter: " << letter << endl;
   cout << "Number: " << number << endl;
   cout << "Decimal Number: " << decimalNumber << endl;
   return 0;
}

/*  Execution results:
Enter a character: a
Letter: a
Number: 97
Decimal Number: 97

Process returned 0 (0x0)   execution time : 41.508 s
Press any key to continue.
Enter a character: A
Letter: A
Number: 65
Decimal Number: 65

Process returned 0 (0x0)   execution time : 2.749 s
Press any key to continue.


*/

Problem B2

   This program demonstrates the string class.
*/

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string movie1;
    string movie2;
    string movie3;

    movie1 = "movie name 1 (For example: Frozen) ";
    cout << movie1 << endl;
    movie2 = "movie name 2 ";
    cout << movie2 << endl;
    movie3 = "movie name 3 ";
    cout << movie3 << endl;
    return 0;
}

/* Execution Results:
movie name 1  
movie name 2  
movie name 3

Process returned 0 (0x0)   execution time : 0.047 s
Press any key to continue.


*/

Comments

Popular posts from this blog

Assignment A

Problem A1 Use the lab instructions given on the Internet at http://voyager.deanza.edu/~oldham Type a copy of the following program. Replace the name  John Smith (Jack)  with your first name, last name, and, if you use one, your nickname in parentheses. Compile it, correct any errors and execute it. Use the following test data: 3.14159 and 2 Copy and paste the execution results under the line    /* Execution Results:   Print the completed program with the execution results. Copy the given information word by word into CodeBlocks. Run the code. Select all and then copy and paste your results under Execution Results.