Question

In: Computer Science

1a. char days[SIZE]; Create a C-String which uses days to store "Monday". 1b.To use things like...

1a. char days[SIZE]; Create a C-String which uses days to store "Monday".

1b.To use things like cout and cin you must use this line of code:

1c. Automatic conversion of an operand to another data type is known as:

1d. To use a string you must use this preprocessor directive:

1e. There are four types of data type modifiers for numerical data, provide one of them.

1f. char ch = 'A'; How would you type cast this to a double

1g. C++'s standard input stream is:

1h. auto number = 4; number = 14.4; cout << number; what is the output?

1l. To generate random numbers you must use this preprocessor directive:

1j. C++'s standard output stream is:

Solutions

Expert Solution

---------------------------------------------------

1a. char days[SIZE]; Create a C-String which uses days to store "Monday".
Answer: First of all question is not clear, if you meant use cstring prepossor directive method to copy
   "Monday" to days char array.
   -> Then answer is: strcpy(days,"Monday")
   if not please comment the question little more clearly. all the questions are clear except this one.
   thank you.


---------------------------------------------------

1b.To use things like cout and cin you must use this line of code:
Answer:
   if the question assumes that the header file iostream is alread imported.
       Statement: using namespace std;
       above Statement makes all the std properties global and can be accessed directly
       without std(std::cin or std::cout)
   else
       #include<iostream> is the line and you will have to use std::cin or std::cout for using cin and cout.

---------------------------------------------------

1c. Automatic conversion of an operand to another data type is known as:
Answer: implicit type conversion. compiler will convert the resultant data type to
   the largest operand data type.

---------------------------------------------------

1d. To use a string you must use this preprocessor directive:
Answer: #include<iostream>
   you should include iostream to use string type.

---------------------------------------------------

1e. There are four types of data type modifiers for numerical data, provide one of them.
Answer: signed , unsigned , long , short are the four types of modifiers.
   type modifiers allow us to modify the meaning of the base data type so it can match our requirement.
  

---------------------------------------------------

1f. char ch = 'A'; How would you type cast this to a double
Answer: double x = (double)ch;
   (double) infront of the char variable ch makes it to cast to double.

---------------------------------------------------

1g. C++'s standard input stream is:
Answer: cin is the c++ standard input stream.

---------------------------------------------------

1h. auto number = 4; number = 14.4; cout << number; what is the output?
Answer:
   Output would be 14.
   auto keyword assigns the data type for given variable at the time of it's initilization of a value.

---------------------------------------------------

1l. To generate random numbers you must use this preprocessor directive:
Answer: #include<cstdlib>
   cstdlib contains the rand() function that generates random number.

---------------------------------------------------

1j. C++'s standard output stream is:
Answer: cout
   cout is the standard output stream for c++;

---------------------------------------------------

ALL THE QUESTIONS ARE ANSWERED . PLEASE SPECIFY QUESTIONS MORE CLEARLY.
1A QUESTION IS QUITE NOT UNDERSTANDABLE, 1B IS LITTLE CONFUSING, IF YOU HAVE ANY DOUBTS
PLEASE COMMENT AND PLEASE LIKE THE ANSWER.


Related Solutions

-Write in C++ -Use Char library functions Write a function that accepts a string representing password...
-Write in C++ -Use Char library functions Write a function that accepts a string representing password and determines whether the string is a valid password. A valid password as the following properties: 1. At least 8 characters long 2. Has at least one upper case letter 3. Has at least one lower case letter 4. Has at least one digit 5. Has at least on special character
Create program which verifies if input string is a valid variable declaration or not. Use C...
Create program which verifies if input string is a valid variable declaration or not. Use C programming language. - This program can only use the following variable types: char, float, and int - Remove any newline \n from input string - The input prompt should say ">>> " - If input declaration is valid, it should print "Valid dec\n" - If input declaration is invalid, it should print "Invalid dec\n" - Make sure the identifier entered matches the rules of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT