Assignment 1
Assignment 1
4. Write a C program for one line code to invert the last four bits of an integer.
5. Write a C++ program that declares two integers, determines whether the first is a
multiple of the second and print the result. (Hint: Use the remainder operator)
6. Write a C++ program that prompts the user to enter two integer values in int variables
val1, val2 and find largest, sum, difference, product and ratio of these values.
7. Write a C++ program that prompts the user to enter three integer values, and then outputs
the values in numerical sequence separated by commas. So, if the user enters the values
10 4 6, the output should be 4,6,10. If two values are the same, they should just be
ordered together. So, the input 4 5 4 should give 4, 4, 5.
8. Write a C++ program to read a sequence of double values into a vector. Think of each
value as the distance between two cities along a given route. Compute and print the total
distance. Find and print the smallest and greatest distance between two neighboring
cities. Find and print the mean distance of the neighboring cities.
10. Write a C++ program to print the accepted number and its reverse number.
Page 1 of 1