Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

EXERCISES 1

1. Mark the following statements as true or false.

a. The first device known to carry out calculations was the Pascaline.
b. Modern-day computers can accept spoken-word instructions but cannot imitate human reasoning.
c. In ASCII coding, every character is coded as a sequence of 8 bits.
d. A compiler translates a high-level program into assembly language.
e. The arithmetic operations are performed inside CPU, and if an error is found, it outputs the logical errors.
f. A sequence of 0s and 1s is called a decimal code.
g. A linker links and loads the object code from main memory into the CPU for execution.
h. Development of a C++ program includes six steps.
i. A program written in a high-level programming language is called a source program.
j. ZB stands for zero byte.
k. The first step in the problem-solving process is to analyze the problem.
l. In object-oriented design, a program is a collection of interacting functions.

2. Name two input devices.

3. Name two output devices.

4. Why is secondary storage needed?

5. What is the function of an operating system?

6. What are the two types of programs?

7. What are the differences between machine languages and high-level languages?

8. What is a source program?

9. Why do you need a compiler?

10. What kind of errors are reported by a compiler?

11. Why do you need to translate a program written in a high-level language into machine language?

12. Why would you prefer to write a program in a high-level language rather than a machine language?

13. What is linking?

14. What are the advantages of problem analysis and algorithm design over directly writing a program in a high-level language?

EXERCISES 2

1. Mark the following statements as true or false.

a. An identifier can be any sequence of digits and letters.
b. In C++, there is no difference between a reserved word and a predefined identifier.
c. A C++ identifier can start with a digit.
d. The operands of the modulus operator must be integers.
e. If a = 4; and b = 3;, then after the statement a = b; the value of b is still 3.
f. In the statement cin >> y;, y can only be an int or a double variable.
g. In an output statement, the newline character may be a part of the string.
h. The following is a legal C++ program:
int main()
{
return 0;
}
i. In a mixed expression, all the operands are converted to floating-point numbers.
j. Suppose x = 5. After the statement y = x++; executes, y is 5 and x is 6.
k. Suppose a = 5. After the statement ++a; executes, the value of a is still 5 because the value of the expression is not saved in another variable.

2. Which of the following are valid C++ identifiers?

a. myFirstProgram
b. MIX-UP
c. C++Program2
d. quiz7
e. ProgrammingLecture2
f. 1footEquals12Inches
g. Mike'sFirstAttempt
h. Update Grade
i. 4th
j. New_Student

3. Which of the following is a reserved word in C++?

a. Const b. include c. Char d. void e. int f. Return

4. What is the difference between a keyword and a user-defined identifier?

5. Are the identifiers firstName and FirstName the same?

6. Evaluate the following expressions.

a. 25 / 3 b. 20 - 12 / 4 * 2 c. 32 % 7 d. 3 - 5 % 7
e. 18.0 / 4 f. 28 - 5 / 2.0 g. 17 + 5 % 2 - 3
h. 15.0 + 3.0 * 2.0 / 5.0

7. If x = 5, y = 6, z = 4, and w = 3.5, evaluate each of the following statements, if possible. If it is not possible, state the reason.

a. (x + z) % y b. (x + y) % w c. (y + w) % x d. (x + y) *w
e. (x % y) % z f. (y % z) % x g. (x *z) % y h. ((x *y) *w) *z

8. Given:

int num1, num2, newNum;
double x, y;

Which of the following assignments are valid? If an assignment is not valid, state the reason.

When not given, assume that each variable is declared.

a. num1 = 35;
b. newNum = num1 - num2;
c. num1 = 5; num2 = 2 + num1; num1 = num2 / 3;
d. num1 * num2 = newNum;
e. x = 12 * num1 - 15.3;
f. num1 * 2 = newNum + num2;
g. x / y = x * y;
h. num2 = num1 % 2.0;
i. newNum = static_cast (x) % 5;
j. x = x + y - 5;
k. newNum = num1 + static_cast (4.6 / 2);

9. Do a walk-through to find the value assigned to e. Assume that all variables are properly declared.
a = 3;
b = 4;
c = (a % b) * 6;
d = c / b;
e = (a + b + c + d) / 4;

10. Which of the following variable declarations are correct? If a variable declaration is not correct, give the reason(s) and provide the correct
variable declaration.
n = 12; //Line 1
char letter = ; //Line 2
int one = 5, two; //Line 3
double x, y, z; //Line 4

11. Which of the following are valid C++ assignment statements? Assume that i, x, and percent are double variables.

a. i = i + 5; b. x + 2 = x; c. x = 2.5 *x; d. percent = 10%;

12. Write C++ statement(s) that accomplish the following.

a. Declare int variables x and y. Initialize x to 25 and y to 18.
b. Declare and initialize an int variable temp to 10 and a char variable ch to 'A'.
c. Update the value of an int variable x by adding 5 to it.
d. Declare and initialize a double variable payRate to 12.50.
e. Copy the value of an int variable firstNum into an int variable tempNum.
f. Swap the contents of the int variables x and y. (Declare additional variables, if necessary.)
g. Suppose x and y are double variables. Output the contents of x, y, and the expression x + 12 / y - 18.
h. Declare a char variable grade and set the value of grade to 'A'.
i. Declare int variables to store four integers.
j. Copy the value of a double variable z to the nearest integer into an int variable x.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91981230
  • Price:- $70

Priced at Now at $70, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Why does some workers earn higher wages than others some

Why does some workers earn higher wages than others, some landowners higher rental income than others, and some capital owners greater profit than others? (Example)Why, in particular, do computer programmers earn more th ...

In a random sample of 100 male students 80 reported that

In a random sample of 100 male students, 80 reported that they were in favour of writing announced tests, while in a sample of 50 female students 23 favoured writing announced tests. Let the male students be population 1 ...

Here is a series of addresses in hexadecimal20w 3cr 10r 16w

Here is a series of addresses in hexadecimal: 20(w), 3C(r), 10(r), 16(w), 20(r), 04(w), 28(r), 6(r), 10(w), 17(w) Assume a LRU replacement algorithm. Draw each of the following caches as it would appear at the end of the ...

Discuss the importance of metadata and some of the various

Discuss the importance of metadata and some of the various ways (Microsoft) SQL Server allows you to expose that information. References welcomed to learn where to find obscure IT information (books, articles, websites)

Mccann co has identified an investment project with the

McCann Co. has identified an investment project with the following cash flows. Year Cash Flow  1   $800  2    1,090 3    1,350 4    1,475 a. If the discount rate is 7 percent, what is the present value of these cash flow ...

Suppose our task is to distinguish between humans and

Suppose our task is to distinguish between humans and non-human objects in an image, which classifier would you choose and why? Decision trees, perceptrons or neural nets.

Question what are the server-side attacks what are the

Question : What are the server-side attacks? What are the techniques a developer can employ to minimize these attacks? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow ...

A sequence of natural numbers a1 a2 an is said to be a

A sequence of natural numbers (a 1 , a 2 , ..., a n ) is said to be a degree sequence if there exists an undirected graph on n vertices {v 1 , v 2 , ..., v n } such that the degree of v i  is a i  for each i = 1, 2, ..., ...

Question questions 1 - 3 are related to singly linked list

Question: Questions 1 - 3 are related to "singly linked list". You must type your answer. 1. What are the fundamental operations of a linked list? 2. What is the main advantage of a linked list over an array? 3. What is ...

Write a program that takes as input an xy center value and

Write a program that takes as input an x,y center value and radii for two circles, draws them in a turtle (Python) window, and prints whether they intersect or not. You should show intersecting circles, and show non-inte ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As