Question

In: Computer Science

Be able to identify valid and non-valid programmer-defined identifiers. Which header file do you need in...

Be able to identify valid and non-valid programmer-defined identifiers. Which header file do you need in order to use the cout and cin objects? Which header file do you need to create string variables? Be able to recognize the correct syntax to define a constant. Be able to recognize the correct syntax to store a character in a char variable. What must you have for every variable you use in a program? Program Given a program, be able to fill in missing blanks with preprocessor directives, namespace statement parts, function definition, punctuation, constant and/or variable names/types, cout/cin statements and return statements. If you can write a complete basic program at this point, you should be good to go.

Solutions

Expert Solution

In order to use the cin and cout , we need to use the namespace std in our program. The syntax to include that is

using namespace std;

In order to just create a string variable and use the basic functionality, we need to include the iostream header file. But if we want to use the complex string functions, we need to include the cstring header file. The syntax is

#include<iostream>

#include<cstring>

In order to declare a constant, we can use

const data_type variable_name = initial_value;

e.g:

const int x = 2;

In order to store a character in a char variable, we use

char ch = character;

In order to use a variable, we need to provide it a data type and assign a value to it.

#include<iostream>

#include<cstring>

using namespace std;

const int x = 2;

void fxn(int a)

{

    cout<<"Argument : "<<a<<endl;

}

int main()

{

    char ch = 'a';

   

    cout<<"ch : "<<ch<<endl;

   

    cout<<"Constant x : "<<x<<endl;

   

    int a = 6;

   

    // call the function

    fxn(a);

   

    return 0;

}


Related Solutions

How do you use header files on a program? I need to separate my program into...
How do you use header files on a program? I need to separate my program into header files/need to use header files for this program.Their needs to be 2-3 files one of which is the menu. thanks! #include #include #include using namespace std; const int maxrecs = 5; struct Teletype { string name; string phoneNo; Teletype *nextaddr; }; void display(Teletype *); void populate(Teletype *); void modify(Teletype *head, string name); void insertAtMid(Teletype *, string, string); void deleteAtMid(Teletype *, string); int find(Teletype...
Research and identify key non-price factors that influence supply and demand. Which do you feel is...
Research and identify key non-price factors that influence supply and demand. Which do you feel is the most important, and why? Be sure to support your answer with a reference(s).
You are required to come up with a single header file (IntList.h) that declares and implements...
You are required to come up with a single header file (IntList.h) that declares and implements the IntNode class (just copy it exactly as it is below) as well as declares the IntList Class interface only. You are also required to come up with a separate implementation file (IntList.cpp) that implements the member functions of the IntList class. While developing your IntList class you must write your own test harness (within a file named main.cpp). Never implement more than 1...
Objective You are given a partial implementation of one header file, GildedRose.h. Item is a class...
Objective You are given a partial implementation of one header file, GildedRose.h. Item is a class that holds the information for each item for the inn. GildedRose is a class that holds an internal listing of many Item objects. This inventory should hold at least 10 items. For this you can use arrays, the std::array class, or even the vector class. Complete the implementation of these classes, adding public/private member variables and functions as needed. You should choose an appropriate...
PYTHON #What you need to do is to transform the file Mkt_data_test.txt #to the format like...
PYTHON #What you need to do is to transform the file Mkt_data_test.txt #to the format like in file in the screenshot # #Your steps to get there: #1.Create a header line with following columns: Time;Bid\Ask;Price;Volume. NOTE NO SPACES #2.Remove all of the timestamp lines, i.e ======== Data: ..... #3.Remove the 1900-01-01 from the timestamp but leave the time itself #4.Get rid of all spaces and empty lines #5.Replace 0 or 1 in the second position with Bid or Ask, Bid...
For a lab, I need to be able to identify an ionic compound out of 50...
For a lab, I need to be able to identify an ionic compound out of 50 other ionic compounds. There is a long list of Cations and Anions that assemble for each compound. We have to develop a procedure to identify which of the ionic compound we have. I have no idea how to begin such a proceadure. Any help is appreciated.
Which of the following three inferences are valid? (There is no need to explain your answers.)...
Which of the following three inferences are valid? (There is no need to explain your answers.) (a)        Premise:          Liu Yang spends two hours every day playing the violin. Conclusion:      Liu Yang wants to be a good violinist. (b)        Premise:          If Liu Yang is in class, she is on campus. Premise:          Liu Yang is on campus. Conclusion:      Liu Yang is in class. (c)        Premise:          If Liu Yang is in class, she is...
Using C++ In a separate header file: Create a new type called "Patient" - you must...
Using C++ In a separate header file: Create a new type called "Patient" - you must use a  class. Give your "Patient" type at least five (5) member elements of your choosing, and at least one member function. You should have member elements to hold patient name, and visitReason (which can change), and other items of your choosing. In your cpp file: Create at least one instance of Patient type (example: CurrentPatient ). Create a menu-driven program OF YOUR OWN DESIGN...
How do you think ? Diversifiable and non-diversifiable risk must be defined before examples may be...
How do you think ? Diversifiable and non-diversifiable risk must be defined before examples may be given. These terms are also understood as unsystematic and systematic risk. Unsystematic risk is a hazard that is inherent within a singular industry instead of the entire market. This risk may be alleviated through the diversification of a portfolio. Alexeev and Tapon’s article discuss the use of diversification to reduce unsystematic risk. They use an example of policy that directly affected the automotive industry....
6.9 Lab: Singly-Linked Lists As an entry-level programmer you have to be able to read, understand...
6.9 Lab: Singly-Linked Lists As an entry-level programmer you have to be able to read, understand existing code and update it (add new features). One of this assignment’s goals is to read about 400 lines of code in five files, compile and run the program, understand it, and change it as required. Download and review the following files (read code and all comments carefully): College.h College.cpp LinkedList.h LinkedList.cpp main.cpp --------------------------------------------------------- //colleges.txt 3 SBCC Santa Barbara City College; 18524 97 ZZC...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT