14. int main() // (5 points) { int X[7] = { 0 }; int k = 2; ifstream F1("Data", ios::in); F1>> X[k]; while (!F1.eof()) { F1>> X [ ++k % 6 ] } Return 0;} X 0 1 2 3 4 5 6 Fill in the elements of the array X using the following data: Data: 2 7 3 5 9 7 1 6 8 4 eof()
Added by Randy R.
Close
Step 1
The program starts with the main function. Show more…
Show all steps
Your feedback will help us improve your experience
Donna Densmore and 87 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Integer numVals is read from input representing the number of integers to be read next. Use a loop to read the remaining integers from input. For each integer read in the loop, output "quantity >>" followed by the integer. End each output with a newline. Ex. If the input is: 3 70 95 80 Then the output is: quantity >> 70 quantity >> 95 quantity >> 80 #include <iostream> using namespace std; int main() { int numVals; int value; cin >> numVals; for (int i = 0; i < numVals; i++) { cin >> value; cout << "quantity >> " << value << endl; } return 0; }
Akash M.
Given a line of text as input, output the number of characters excluding spaces, periods, or commas. Ex: If the input is: Listen, Mr. Jones, calm down. the output is: 21 Note: Account for all characters that aren't spaces, periods, or commas (Ex: "r", "2", "!"). #include <iostream> #include <string> using namespace std; int main() { string userText; // Add more variables if needed getline(cin, userText); // Gets entire line, including spaces // Type your code here return 0; }
Deepak K.
Modify Counter into a program that tells you only the number of lines that are a) shorter than ten characters and b) longer than twenty. Complete the following file: counter.cpp #include <iostream> #include <cctype> using namespace std; int main() { int charCount = 0; int lineCount = 0; char ch; while (cin.get(ch)) { if (ch == '\n') { lineCount++; } else { charCount++; } } cout << "Characters read: " << charCount << endl; cout << "Lines read: " << lineCount << endl; return 0; }
Derrick D.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD