Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Short Answer Questions 1. Write a single C++ statement that will: Print the string “C++” using the variable: string s = “Introduction to C++”. 2. Change the letter ‘c’ to ‘C in the following string:...

1 answer below »
Short Answer Questions
1. Write a single C++ statement that will:    
Print the string “C++” using the variable:     string s = “Introduction to C++”.
2. Change the letter ‘c’ to ‘C in the following string:    
Reprint the string with “C” given the code and using the string: string greeting = “Introduction to c++”
3. Write the C++ statement or statements that will:    
Print the answer for regular division of the real numbers a / b + c and print the answer for integer division of the same values for integer numbers d / e + f.
For example, given float a=13, b=3, c = 10, the statements would print :
Regular division result = XXXXXXXXXX
Integer division result = 14
4. Write the C++ statement or statements that will generate a random number between 100 and 110:    
5. Write a C++ statement or statements that will:    
Print the first two digits and the last two digits of any 4 digit number stored in an integer variable n.     
For example, given int n = 5623, print
XXXXXXXXXX.
6. Write C++ statements that will align the following three lines as printed in two 20 character columns.
Name     Years President
A
aham Lincoln             XXXXXXXXXX
Thomas Jefferson             XXXXXXXXXX
7. Write a C++ statement or statements that will Output if a string has a length greater than 10, equal to 10 or less than 10.
Examples :
string str1 = “Four Score and Seven Years Ago” would output “String Length > 10”
string str2 = “Good Day” XXXXXXXXXXwould output “String Length < 10”
string str3 = XXXXXXXXXX” XXXXXXXXXXwould output “String Length = 10”
8. Create a truth table and determine the results for the following equation and values
Equation : bool b = ((a+4< 7) || ((b-a > 10) && !(c*a == 8)))
Values : a = 2; b = 8; c = 4
Answered 7 days After Jun 19, 2021

Solution

Aditya answered on Jun 26 2021
149 Votes
Assign C++ 26_06_2020/Document.docx
The Assignment is done in C++.
q1.
String class in built substr() function is used.
q2.
String class in built replace() function is used.
q3.
expression first evaluated using float datatype to get real values then type casted to int to get integer values.
q4.
and() li
ary function used to generate random integers and then
ought within the range between 100 and 110 by taking modulo by 11 and adding 100.
q5.
first two of 4 digits got by dividing by 100 and the last 2 digits retrieved by taking modulo by 100.
q6.
Li
ary function setw() used to pad the strings on the right.
q7.
String class in built size() function used to find the size of the string and compare it with 10.
q8.
truth table of boolean expression ((p)||((q)&&!(r))) constructed by evaluating it over all possible values of p, q and r.
then complete expression evaluated for p = (a+4<7), q = (b-a>10) and c = (c*a==8)
where : a = 2, b = 8, and c = 4
Assign C++ 26_06_2020/q1.cpp
Assign C++...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here