Вы находитесь на странице: 1из 8

Fullerton College

Department of Mathematics and Computer Science


CSCI 123F Introduction to C++

Homework Assignment 1
Geovanni Gonzalez
Mr. Haney Williams
Date Due: 11 February, 2014

1) What are the 5 components of the hardware in the computer?

Solution:
The five components of the hardware in a computer are the main memory, the secondary
memory, the processor (CPU), the input devices, and the output devices.

2) Complete the memory architecture diagram below indicate where Cache, Main
Memory (RAM), Secondary Memory, tertiary Memory, and CPU Registers belong on
the diagram, and indicate how the size, speed and price decrease or increase based on

Speed and Price Increase

Speed and Price Decrease

the arrows directions:

CP
U
Re
gis
ter

Cache

Main Memory
Secondary Memory
Tertiary Memory
Size

3)
a. Define Machine Language.
b. Give an example of Low Level Language
c. Give an example of High Level Language

Solution:
a. Machine Language consists of only 0s or 1s or, bits. It is the only language that
computers could understand.
b. Low Level Language is a step above machine language, the only difference being
the introduction of words, adding a sense of abstraction. An example would be
assembly language
c. High Level Language is the language that closely resembles the human language
making it easy for humans to read and understand. Examples include C++, java,
python, C#, etc.

4) Define
a. Compiler, and
b. Linker

Solution:
a. A compiler translates high level language into machine language.
b. A linker links ready-made libraries and code with the programmers object code.

5)
a. Write a program that displays as it shows below
My name is **YOUR NAME IS HERE**
And I LOVE CSCI 123F very much
b. As our Counting inventory of the shampoo bottle at Costco example, write a
program that asks the user for the count of the shampoo bottles, then asks the
user to enter the price for each shampoo bottle, and then it displays the total
price. (Assume the price is an integer, in other words it is only in dollar value)
Ex.

Please enter the count of the shampoo bottles: 12

Please enter the price of each shampoo bottle (in dollars): 7


The total price is: 84 dollars

Algorithm:
1. Computer displays My name is Geovanni Gonzalez And I LOVE CSCI 123F very much

Flow Chart:

Source Code:
#include <iostream>
using namespace std;
int main()
{
//Display on screen "My...Gonzalez"
cout << "My name is Geovanni Gonzalez\n";
//Display on screen "And...much"
cout << "And I LOVE CSCI 123F very much.\n";
return 0;
}

Output:

Algorithm:
1.
2.
3.
4.
5.
6.

Screen displays Please enter the count of the shampoo bottles:


Computer gets and stores data into a variable, say numberOfShampooBottles.
Screen displays Please enter the price of each shampoo:
Computer gets and stores data into a variable, say priceOfShampooBottles.
Computer multiplies the two variables and stores the data into a variable, totalPrice.
Screen displays The total price is: along with totalPrice.

Flow Chart:

Source Code:
#include <iostream>
using namespace std;
int main()
{
//Declare and initialize variables
int numberOfShampooBottles = 0;
int priceOfShampooBottles = 0;
int totalPrice = 0;
//Display to ask user to enter number of bottles
cout << "Please enter the count of the shampoo bottles: ";
//Get number of bottles from user
cin >> numberOfShampooBottles;
//Display to ask user to enter price of bottles
cout << "Please enter the price of each shampoo bottle (in dollars):";
//Get price of shampoo bottles
cin >> priceOfShampooBottles;
//Calculate the total price
totalPrice = numberOfShampooBottles * priceOfShampooBottles;
//Display the total price along with the calculation
cout << "The total price is: " << totalPrice << " dollars" << endl;
return 0;
}

Output:

Вам также может понравиться