C++ find output programs
- C++ Operators | Find output programs | Set 1
- C++ Operators | Find output programs | Set 2
- C++ const Keyword | Find output programs | Set 1
- C++ const Keyword | Find output programs | Set 2
- C++ Manipulators | Find output programs | Set 1
- C++ Manipulators | Find output programs | Set 2
- C++ Reference Variable | Find output programs | Set 1
- C++ Reference Variable | Find output programs | Set 2
- C++ Conditional Statements | Find output programs | Set 1
- C++ Conditional Statements | Find output programs | Set 2
- C++ Switch Statements | Find output programs | Set 1
- C++ Switch Statements | Find output programs | Set 2
- C++ goto Statement | Find output programs | Set 1
- C++ goto Statement | Find output programs | Set 2
- C++ goto Statement | Find output programs | Set 2
- C++ Looping | Find output programs | Set 1
- C++ Looping | Find output programs | Set 2
- C++ Looping | Find output programs | Set 3
- C++ Looping | Find output programs | Set 4
- C++ Looping | Find output programs | Set 5
- C++ Default Argument | Find output programs | Set 1
- C++ Default Argument | Find output programs | Set 2
- C++ Arrays | Find output programs | Set 1
- C++ Arrays | Find output programs | Set 2
- C++ Arrays | Find output programs | Set 3
- C++ Arrays | Find output programs | Set 4
- C++ Arrays | Find output programs | Set 5
- C++ Strings | Find output programs | Set 1
- C++ Strings | Find output programs | Set 2
- C++ Strings | Find output programs | Set 3
- C++ Strings | Find output programs | Set 4
- C++ Strings | Find output programs | Set 5
- C++ Class and Objects | Find output programs | Set 1
- C++ Class and Objects | Find output programs | Set 2
- C++ Class and Objects | Find output programs | Set 3
- C++ Class and Objects | Find output programs | Set 4
- C++ Class and Objects | Find output programs | Set 5
- C++ Constructor and Destructor | Find output programs | Set 1
- C++ Constructor and Destructor | Find output programs | Set 2
- C++ Constructor and Destructor | Find output programs | Set 3
- C++ Constructor and Destructor | Find output programs | Set 4
- C++ Constructor and Destructor | Find output programs | Set 5
- C++ this Pointer | Find output programs | Set 1
- C++ this Pointer | Find output programs | Set 2
- C++ this Pointer | Find output programs | Set 3
- C++ Structures | Find output programs | Set 1
- C++ Structures | Find output programs | Set 2
- C++ Structures | Find output programs | Set 3
- C++ Structures | Find output programs | Set 4
- C++ Structures | Find output programs | Set 5
- C++ Friend Function | Find output programs | Set 1
- C++ Friend Function | Find output programs | Set 2
- C++ Function Overloading | Find output programs | Set 1
- C++ Function Overloading | Find output programs | Set 2
- C++ Function Overloading | Find output programs | Set 2
- C++ Function Overloading | Find output programs | Set 3
- C++ Static Variables and Functions | Find output programs | Set 1
- C++ Static Variables and Functions | Find output programs | Set 2
- C++ Static Variables and Functions | Find output programs | Set 3
- C++ Static Variables and Functions | Find output programs | Set 4
- C++ Static Variables and Functions | Find output programs | Set 5
- C++ Operator Overloading | Find output programs | Set 1
- C++ Operator Overloading | Find output programs | Set 2
- C++ Operator Overloading | Find output programs | Set 3
- C++ Operator Overloading | Find output programs | Set 4
- C++ Operator Overloading | Find output programs | Set 5
- C++ Enumeration | Find output programs
- C++ Inheritance | Find output programs | Set 1
- C++ Inheritance | Find output programs | Set 2
- C++ Inheritance | Find output programs | Set 3
- C++ Inheritance | Find output programs | Set 4
- C++ Inheritance | Find output programs | Set 5
- C++ Exceptional Handling | Find output programs | Set 1
- C++ Exceptional Handling | Find output programs | Set 2
- C++ Exceptional Handling | Find output programs | Set 3
- C++ Virtual Functions | Find output programs | Set 1
- C++ Virtual Functions | Find output programs | Set 2
- C++ Virtual Functions | Find output programs | Set 3
- C++ Templates | Find output programs | Set 1
- C++ Templates | Find output programs | Set 2
- C++ Preprocessor | Find output programs | Set 1
- C++ Preprocessor | Find output programs | Set 2
- C++ Preprocessor | Find output programs | Set 3
- C++ Signal Handling | Find output programs | Set 1
- C++ Namespace | Find output programs | Set 1
- C++ Namespace | Find output programs | Set 2
- C++ Dynamic Memory Allocation | Find output programs | Set 1
- C++ Dynamic Memory Allocation | Find output programs | Set 2
- C++ Dynamic Memory Allocation | Find output programs | Set 3
Answer Program 1:
Output:
Explanation:
The above code is used to count the digits of the number.
Here we declared two local variables i and num with initial values 0 and 5432 respectively. The loop condition will be true till the variable num is greater than 0. Now we dry run the program:
i=0, num=5432, loop condition is true. num = 5432/10; num = 543; And I become 1. i=1, num=543, loop condition is true. num = 543/10; num = 54; And I become 2, loop condition is true. num = 54/10; num = 5; And I become 3, loop condition is true. num = 5/10; num = 0;
And, when i become 4 and the loop condition will false. Then, we printed the value of i that will be equal to the number of digits of the specified number.
Answer Program 2:
Output:
Explanation:
The code is using to calculate the factorial of a number. In the above code, we calculated the factorial of variable num that contains 5.
Now we understand the program. Here we declared two local variables f and num with initial values 1 and 5 respectively.
Here we used while loop, that will execute till variable num contains a value greater than 0. Now we dry run the while loop.
Interation1: f=1, num=5 and condition is true f = 1*5 = 5 And decrease num that become 4. Interation2: f=5, num=4 and condition is true f = 5*4 = 20 And decrease num that become 3. Interation3: f=20, num=3 and condition is true f = 20*3 = 60 And decrease num that become2. Interation4: f=60, num=2 and condition is true f = 60*2 = 120 And decrease num that become 1. Interation5: f=120, num=1 and condition is true f = 120*1 = 120 And decrease num that becomes 0. And then the condition will false. And then print 'f', it will print 120, which is the factorial of 5.
Answer Program 3:
Output:
Explanation:
The above code will print the above pattern.
Let's understand the program step by step.
Here we declared two variables i and j and initialized with 1. Here we used nested looping.
Iteration1: It will print 1. Iteration2: It will print 12. Iteration3: It will print 123. Iteration4: It will print 1234. Iteration5: It will print 12345. Then the outer loop will terminate.
need an explanation for this answer? contact us directly to get an explanation for this answer