C++ Programming (Assignment), Assignments of Computer Programming

Computer Programming Lecture - All about C++ Programming

Typology: Assignments

2020/2021

Uploaded on 06/19/2021

iamjoanajqn
iamjoanajqn 🇵🇭

1 document

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
NAVAL, JOANA JANE Q. 2nd Semester COMPUTER PROGRAMMING
BSCS – 1D MS. MEO LIM GABAS
1. What is the difference between initialization and assignment?
-Initialization gives a variable an initial value at the point when it is
created. Assignment gives or sets the variable of a value at some point
after the variable is created.
2. When does undefined behavior occur? What are the consequences of
undefined behavior?
-If undefined behaviour occurs, a compiler is allowed to do anything it
wants. The consequences of undefined behavior in C/C++ programs
come from three sources: the definitions of U in the respective C and
C++ language standards, the difference in the treatment of UB by
different compiler implementations, and the sloppiness of
programmers unaware of the consequences of UB.
3. Write the steps that will transform the input into the output. Give at
least one example.
pf2

Partial preview of the text

Download C++ Programming (Assignment) and more Assignments Computer Programming in PDF only on Docsity!

NAVAL, JOANA JANE Q. 2 nd^ Semester COMPUTER PROGRAMMING BSCS – 1D MS. MEO LIM GABAS

  1. What is the difference between initialization and assignment?
    • Initialization gives a variable an initial value at the point when it is created. Assignment gives or sets the variable of a value at some point after the variable is created.
  2. When does undefined behavior occur? What are the consequences of undefined behavior? - If undefined behaviour occurs, a compiler is allowed to do anything it wants. The consequences of undefined behavior in C/C++ programs come from three sources: the definitions of U in the respective C and C++ language standards, the difference in the treatment of UB by different compiler implementations, and the sloppiness of programmers unaware of the consequences of UB.
  3. Write the steps that will transform the input into the output. Give at least one example.

NAVAL, JOANA JANE Q. 2 nd^ Semester COMPUTER PROGRAMMING BSCS – 1D MS. MEO LIM GABAS An assignment statement sets and/or re-sets the value stored in the storage location/s denoted by a variable name; in other words, it copies a value into the variable. The assignment operator allows us to change the value of a modifiable data object (for beginning programmers this typically means a variable). It is associated with the concept of moving a value into the storage location (again usually a variable). Within most programming languages the symbol used for assignment is the equal symbol. But bite your tongue, when you see the = symbol you need to start thinking: assignment. The assignment operator has two operands. The one to the left of the operator is usually an identifier name for a variable. The one to the right of the operator is a value. Simple Assignment

age = 21

The value 21 is moved to the memory location for the variable named: age. Another way to say it: age is assigned the value 21.