What is the use of #include




5/5 - (2 votes)

Given the following program, answer the questions below: a) What is the value of n after the assignment n = j – j / i * i ? b) What is the use of #include <iostream ? c) If you have int x and do x = 2.45, the compiler will issue a warning, but it will compile. What is the effect of that assignment ? d) Why would the compiler issue a warning? What could be “dangerous” about that assignment? how come a warning is not issued when you assign an int value to a float variable ? e) Given a variable float f, what would be the value of f after assigning f = 24;
#include <iostream int main (void) { int n, i =5, j = 8;
9/5/14, 12:24 PM
Page 2 of 3file:///Users/rafa/Rafa/Materials/CplusplusOnline/Cpp%20Course%20FA%202014/Assignment%202.html
n = j – j / i * i ; cout << “The result is ” << “—–” << n; return 0; } C++ Program Write a program that prints to cout, separated by a space, the digits of any three digit integer. You will need one variable, named, for example, value, for the number (int value) to be broken down into its digits. You might also need other variables to store the digits as you get them. The structure of your program could be: #include <iostream int main() { int number; int digit1, digit2, digit3; // place holders for the digits. cout << “Type a three digit number\n”; cin number;
// your code here
return 0; } Hint: You can do this by using repeated divisions by 10, and remembering that dividing two integers always resuts in an integer. For example 6/5 would yield a result of 1. You can use the % operation If you input a number like 345 your ouput should be 3 4 5 (its three digits separated by
9/5/14, 12:24 PM
Page 3 of 3file:///Users/rafa/Rafa/Materials/CplusplusOnline/Cpp%20Course%20FA%202014/Assignment%202.html
a space)