Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


C++ Programming Code Examples

C++ > For Loops and While Loops Code Examples

Following C++ program first ask to the user to enter the value of n and then ask to enter the n Number to add them. This program add all n numbers entered. To add n numbers in C++
We can use "break" statement inside loops to terminate a 'loop & exit' it. In above example loop execution 'continues' until either n>=20 or entered score is negative. This statement
It's used in switch case control structure after the case blocks. Generally all cases in switch case are followed by a "Break Statement" to avoid the subsequent cases (see the example
As you can see that the output is missing the value 3, however the for loop 'iterate' though the num value 0 to 6. This is because we have set a condition inside loop in such a way, that
The statement is executed, then expression is evaluated. If it is true, statement is evaluated again, and so on. When 'expression' becomes false, the 'loop terminates'. Experience shows
The largest integer which can perfectly divide 2 integers is known as GCD or HCF of those 2 numbers. The logic of this program is simple. In this, small integer between "number1" and
Control statement itself has three parts: for ( "initialization"; test condition; run every time command ). "Initialization" part is performed only once at for loop start. We can initialize a
A Loop is said to be infinite when it executes repeatedly & 'never stops'. It usually happens by mistake. When you set the condition in for loop in such a way that it never return false, it
This Loop would never end as 'decrementing' the value of i which is 1 so the condition i<=6 would never return false. A "While Loop" that never stops is said to be "Infinite While Loop",
The digit sum of a given integer is the sum of all its digits (digit sum of '84001' is calculated as 8+4+0+0+1 = 13). Odd number is an integer which is not a multiple of two. If it is "divided"
The statements within the while loop would keep on getting executed till the "condition" being tested remains "true". When condition becomes false, the control passes to the first