Professional Documents
Culture Documents
Learning Activity 4 - Lim
Learning Activity 4 - Lim
Learning Activity 4 - Lim
LIM
BSCE – 1A
Answer: (15>= 3 *5 || 25 >= 24 +2) //evaluates to true && 12<=25/3 && 22 - -34 >= 20; //evaluates to
false.
Answer: 10 > 25 && !(30!=25) //evaluates to false || 10 + 20== 45 - 10; //evaluates to false.
3. What is the result of 25 / 4? How would you rewrite the expression if you wished the result to be a
floating-point number?
It rewrite as 25.0 / 4.0, 25.0 / 4, or 25 / 4.0. or in the program…
4. Suppose m and r are integers. Write two different ways of C++ expression for mr^2, store the result
to variable result. The other expression uses the math function for r^2 and the other doesn’t use the
math function but the equivalent expression.
Answer:
int a = 6; int b = a-
int a = 6; int b = -; int c = --b + a;
a++; int c = ++b + cout << a << endl;
a++; cout << a << cout << b << endl;
endl; cout << b << cout << c << endl;
endl;
cout << c << endl;
Result: program 1
Result: Program 2
8. Write the line of code for the following statements.
a. Declare a string named favFood. Int string favfood;
b. Assign a value pizza to that variable of letter a.
favfood=a;
c. Stream in the string from input.
cin >> facfood;
d. Declare and assign string named age String as “25”.
String agestring = 25
e. Extract the age String value to integer value named age.
Int agestring, age; // a:?, b:? agestring = 25;
// a:25, b:? age= a // a:25, b:25
age= 25 // a:25, b:25