C++ program to find the sum of all integer between 100 and 200 which are divisible by 9.

Download This Tutorial in PDF

Write a C++ program to find the number and sum of all integer between 100 and 200 which are divisible by 9.

Flowchart of the program to find the number and sum of all integer which are divisible by 9

C++ program to find the sum of all integer between 100 and 200 which are divisible by 9.

Source code in C++

Output

Please enter numbers between 100 & 130 which are divisible by 9:

number divisible by 9 is: 108

number divisible by 9 is : 117

number divisible by 9 is: 126

the sum of all numbers divisible by 9 is: 351

 

Excercise

Find the possible mistakes in the following Shamil’s Flow Table of the program to find the number and sum of all integer which are divisible by 9.

LoopIf conditionLines will Be ExecutedActual work to do
i=101False1,2,3,4,5,6,7,8,9,10,15,16,17,8
i=102False1,2,3,4,5,6,7,(8,9,10,15,16,17)2 times,8
i=103False1,2,3,4,5,6,7,(8,9,10,15,16,17)3 times,8
i=104False1,2,3,4,5,6,7,(8,9,10,15,16,17)4 times,8
i=105False1,2,3,4,5,6,7,(8,9,10,15,16,17)5 times,8
i=106False1,2,3,4,5,6,7,(8,9,10,15,16,17)6 times,8
i=107False1,2,3,4,5,6,7,(8,9,10,15,16,17)7 times,8
i=108True1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,8Sum=sum+i

Sum=0+108

Sum=108

i=109False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,8,9,10,15,16,17,8
i=110False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)2 times,8
i=111False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)3 times,8
i=112False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)4 times,8
i=113False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)5 times,8
i=114False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)6 times,8
i=115False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)7 times,8
i=116False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8 times,8
i=117True1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8 times,8,9,10,11,12,13,14,15,16,17,8Sum=sum+i

Sum=108+117

Sum=225

i=118False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8times,8,9,10,11,12,13,14,15,16,17,8,9,10,15,16,17,8
i=119False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8 times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)2 times,8
i=120False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8 times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)3 times,8
i=121False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8 times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)4times,8
i=122False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8 times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)5 times,8
i=123False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8 times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)6 times,8
i=124False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8 times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)7 times,8
i=125False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8 times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8 times,8
i=126True1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8times,8,9,10,11,12,13,14,15,16,17,8Sum=sum+i

Sum=225+126

Sum=351

i=127False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8times,8,9,10,11,12,13,14,15,16,17,8,9,10,15,16,17,8
i=128False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)2times,8
i=129False1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)3times,8
i=130

loop terminates

1,2,3,4,5,6,7,(8,9,10,15,16,17)7times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)8times,8,9,10,11,12,13,14,15,16,17,(8,9,10,15,16,17)4times,18,19Sum of all numbers divisible by 9=351

Subscribe for Friendship

Latest posts by Prof. Fazal Rehman Shamil (see all)

Buy advertisement space on T4Tutorials

For more details email [email protected]