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