Question

In: Computer Science

Hw questions 1. Write a single C++ statement that will:      Print the string “C++” using the...

Hw 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 = 14.3333       

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

56    23.

6. Write  C++ statements that will align the following three lines as printed in two 20 character columns.

Name                                                 Years President

Abraham Lincoln                                 1860-1865

Thomas Jefferson                               1801-1809


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”                                            would output “String Length < 10”

string str3 = 0123456789”                                          would 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

9. Write a program using Atom and submit via Blackboard.

a. Request an integer whole dollar amount from the console.

b. Using the least amount of bills ($50,$20,$10,$5,$1) necessary, calculate how many of each bill type you will need to get to that value.

Output Example 1 (input is bold and italicized)

Enter a whole dollar amount as n integer: 633                                                           

You will need:

12   $50 bill(s).

1   $20 bill(s).

1 $10 bill(s).

0   $5 bills(s).

3    $1 bill(s).

Output Example 2 (input is bold and italicized)

Enter a whole dollar amount as an integer: 364                                                        

You will need:

7     $50 bill(s).

0     $20 bill(s).

1   $1 bill(s).

0     $5 bills(s).

4     $1 bills(s).

Solutions

Expert Solution

1.

#include<iostream>
using namespace std;
int main()
{

string s="Introduction to C++";
cout<<"The given string is :\n"<<s;

}

2.

#include<iostream>
using namespace std;
int main()
{

string s="Introduction to C++";
string greeting="Introduction to c++";
cout<<"The given string is :\n"<<s;
cout<<"\nAnother string is :\n"<<greeting<<endl;

}

3.

#include<iostream>
using namespace std;
int main()
{

float a,b,c,f;
int d;
cout<<"\nEnter the 1st number :";
cin>>a;
cout<<"\nEnter the 2nd number :";
cin>>b;
cout<<"\nEnter the 3rd number :";
cin>>c;
d =(int) a/b + c;
f = a/b + c;
cout<<"\nRegular division result :"<<f;
cout<<"\nInteger division result :"<<d;


}

4.

#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
srand(time(NULL));

int upper=110,lower=100;
int d = (rand()%(upper - lower +1))+lower;
cout<<"The random number between 100 and 110 is :\n"<<d<<endl;

}

Please don't post so many questions at once. We have been asked to solve only one question or 4 sub question at a time. So please don't downvote and repost remaining question again. Will surely solve. Also if you have any questions comment down and please? upvote thanks


Related Solutions

Write a Python program which prompts the user to input a string. Then, print the string...
Write a Python program which prompts the user to input a string. Then, print the string in reverse to the terminal Sample output Please enter a word: "zeus" The reverse of zeus is suez Hint: There are several ways to accomplish this. Recall that a string is an itterable object and therefore can be used with a for loop
Modify HW#1. C++ use,Write a multithreaded program that tests your solution to HW#1. You will create...
Modify HW#1. C++ use,Write a multithreaded program that tests your solution to HW#1. You will create several threads – for example, 100 – and each thread will request a pid, sleep for a random period of time, and then release the pid. (Sleeping for a random period approximates the typical pid usage in which a pid is assigned to a new process, the process executes and terminates, and the pid is released on the process’ termination).On UNIX and Linux systems,...
For these of string functions, write the code for it in C++ or Python (without using...
For these of string functions, write the code for it in C++ or Python (without using any of thatlanguage's built-in functions) You may assume there is a function to convert Small string into the language string type and a function to convert your language's string type back to Small string type. 1. int [] searchA,ll(string in...str, string sub): returns an array of positions of sub in in...str or an one element array with -1 if sub doesn't exist in in...str
5. Write a C++ statement or statements that will:       Print the first two digits and the  last...
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 56    23. 6. Write  C++ statements that will align the following three lines as printed in two 20 character columns. Name                                                 Years President Abraham Lincoln                                 1860-1865 Thomas Jefferson                               1801-1809 7.  Write a C++ statement or statements that will Output if a string has a length greater than 10, equal...
USING C# 1. Write a program that takes outputs a string, an integer and a floating-point...
USING C# 1. Write a program that takes outputs a string, an integer and a floating-point number separated by commas. Sample output: Bob Marley, 20, 5.2 2. 2. Write a program that asks the user for a string of letters of any size (no spaces), and finally a special character (values 33 to 47 in the Ascii table, or ‘!’ to ‘/’). Generate a random number of any size, integer or floating point, and combine those three pieces of information...
How To Print Nice Padding Character in a String in C++? 1. User input the width...
How To Print Nice Padding Character in a String in C++? 1. User input the width = 14 2. User input the padding character = + Example output: ++Hello World++ Thanks in advance.
Write a single C++ statement to accomplish each of the following.                               &nbs
Write a single C++ statement to accomplish each of the following.                                                  (6 pts) Read an integer from the user at the keyboard and store the value entered in an integer variable age. Compute the product of the 3 integers contained in variables x, y and z and assign the result to the variable result
Using pseudocode or C++ code, write code to print “small” if the magnitude M of an...
Using pseudocode or C++ code, write code to print “small” if the magnitude M of an earthquake is in the range [0, 3), “medium” if M is in the range [3, 6), “large” if M is in the range [6, 9) and “epic” if M is greater than or equal to 9, where M is input by a user via the keyboard. (in c++)
write a program that will print a truth table for p ^ ~q. Using C++ please.
write a program that will print a truth table for p ^ ~q. Using C++ please.
I need to write a C++ program that appends "not" into the string without using the...
I need to write a C++ program that appends "not" into the string without using the append method or any standard libraries. It should return the string if there isn't an "is" in it. Examples: is is = is not is not This is me = This is not me What is yellow? = What is not yellow? The sky is pink = The sky is not pink isis = isis What happened to you? = What happened to you?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT