Question: is it correct ? (c++) Section 1.4 Flow of Control EXERCISES SECTION 1.4.3 Exercise 1.16: Write your own version of a program that prints the

is it correct ? (c++)  is it correct ? (c++) Section 1.4 Flow of Control EXERCISES
SECTION 1.4.3 Exercise 1.16: Write your own version of a program that

Section 1.4 Flow of Control EXERCISES SECTION 1.4.3 Exercise 1.16: Write your own version of a program that prints the sum of a set of integers read from cin. 1.4.4 The if Statement Like most languages, C++ provides an it statement that supports conditional exe- cution. We can use an if to write a program to count how many consecutive times each distinct value appears in the input: #include int main() // currval is the number we're counting: we'll read new values into val int curr Val - 0, val = 0; // read first number and ensure that we have data to process if (std::cin>> currval) { int ant - 1; // store the count for the current value we're processing while (std::cin>> val) ( 7 read the remaining numbers if (val - currval) // if the values are the same ++ent // add 1 to cnt else { // otherwise, print the count for the previous salue std::cout int main() { // currval is the number we're counting; we'll read new values into val int currVal = 0, val = 0; // read first number and ensure that we have data to process if (std::cin >> currval) { int cnt = 1; // store the count for the current value we're processing while (std::cin>> val) { // read the remaining numbers if (val == currval) // if the values are the same ++ent; // add 1 to cnt else { // otherwise, print the count for the previous value std::cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!