C++ exercises


Exercise T1

Write a program that asks the user to type in numbers. After each entry, the program should report the cumulative sum of the entries to date. The program should terminate when the user enters 0. For example, it can look like this:
Enter a number
The sum of numbers: 5
Enter a number
The sum of numbers: 11
Enter a number
The sum of numbers: 13
Enter a number
Press <RETURN> to close the console

Exercise T2

Write a program that requests the user to enter two integers. The program should then calculate and report the sum of all the integers between and including the two integers. At this point, assume that the smaller integer is entered first. For example, if the user enters 2 and 9, the program should report that the sum of all the integers from 2 through 9 is 44.

Exercise P1

Write a program that asks the user to enter two integers to be stored in the variables a and b respectively. Declare two pointers ptrA and ptrB. Let ptrA point to a and ptrB point to b. Show the values of a and b using pointers ptrA and ptrB.

Exercise G1

Create a Qt program that draws something like this on the screen:


0 komentarzy