 Hello friends, I am Naval Yamal working as an assistant professor in Mechanical Engineering Department, Wolchen Institute of Technology, Solapur. In this video, we are going to see the programs on C++ Part 2, Learning Outcome. At the end of this session, students will be able to understand basic programs of C++. The first program we will see is to swap the numbers using the temporary variable. So we are using as Include Iostream, int main, all this explained in the other video. So I am taking three variables and assigning the values like int a equal to 5, b equal to 10, I am taking the third variable as temporary that is T E M P, C out before swapping the numbers will be a equal to 5 and b equal to 10, C out a equal to a value is shown, b equal to b value is shown that is a equal to 5, b equal to 10, then temp equal to a. So whatever the value of a is stored that comes in temp, then a equal to b. Now the value of a will be empty, the value of b which is 10 that goes in value of a and b equal to 10. So in the first line the temporary equal to a, the value of a was stored in temp and now the temp value is stored in again b. So C out after swapping C out a equal to we call a that a is nothing but the value of b and again we call b value that b value is nothing but temp. So finally the output will be before swapping a equal to 5, b equal to 10 after swapping the number gets swapped then a equal to 10 and you get 5 equal to b. So we will see that the second program that is C plus less program to swap numbers without using temporary variables. So in the previous program we have taken three variables but in this program we are taking only two variables and temporary variable is neglected. So first three lines are same int a equal to 5, b equal to 10. So we are not taking the third variable. So C out before swapping C out a equal to we call a value b equal to we call b value that comes to a equal to 5 and b equal to 10. So the logic here is a value is equal to a plus b I have written a comment here that is 5 plus 10 where a value is 5 b value is 10 you get value 15. So the new a value is 15 b equal to a minus 10 the new value a is 15 minus the old value 10 so 15 minus 10 gives you 5. So now the latest b value is 5 and the latest a value is 15. The next equation we are using a equal to a minus b that the latest a value is 15 and the latest b value is 5 that comes to 10. So if you look b and a value you get 5 and 10 so after swapping the numbers will be C out a equal to we are calling a the new a value is 10 and the we are calling b value and the new b value is 5. So the final output will be before swapping a equal to 5 b equal to 10 after swapping a equal to 10 and b equal to 5. This program is without using temporary variables. So the next program is C plus plus program to compute quotient and remainder. So we are using a math as a header file in this. So we are taking four variables that is dividend, divisor, quotient and remainder all as an integer. So C out computing quotient and remainder, C out input the dividend and divisor, C in so the two numbers entered by the user stores in dividend and divisor. So here the logic is quotient is equal to dividend divided by divisor that division sign is nothing but a backslash and if you want to calculate a remainder that is dividend modulus or a person symbol then divisor. So C out will be quotient of a division we are calling quotient and we have calculated quotient as dividend divided by divisor that is using division symbol and to calculate remainder we are using dividend person sign or it is also called as modulus divisor and C out remainder of the division is we are calling remainder and L to get the cursor to the next line. So the output for this program will be like computing, compute quotient and remainder, input the dividend and divisor if the user center 25 and 23, 25 as dividend, 23 as divisor the quotient of a division is 8 as 25 divided by 3 you get quotient 3 and the remainder will be 1. So in this program the logic is if you want to find a quotient we are using divide by sign and if you want to find a remainder we are using person symbol or also called as modulus. So we will see the next program that is to convert a given number in days and months is very simple again we are using two header files here and we are taking three variables int number a comma b, C out enter any number C in that is stored in number. So here a equal to number divided by 30 for example if a user enters 45 as a number 45 divided by 3 you get a quotient as 1, b equal to number person 30 that is modulus 45 modulus of 30 the remainder is 15 so C out months equal to we are calling a and days equal to we are calling b. So your output will be suppose if a user enters 45 so the output will be months equal to 1 and days equal to 45. So this program is only for the months which is coming with 30 days. So think for the program to convert a given number in hours and minutes pause the video for few seconds and think on the solution. So we will see the logic here very simple we are using two header files again and same the program is same as the previous program we are taking three variables number a comma b enter any number and that stored in number. So here a equal to number divided by 60 in previous program it was divided by 30 only and here b equal to number person 60. So a equal to we will give you the quotient and b will be equal to give you the remainder. So hours we are calling a and for minutes we are calling b and written 0 in the output for the program will be enter any number suppose if the user enters 90 then hours will be 1 and minutes will be 30. So we will see the last program that is C++ program to separate individual digits from an integer. So we are using two header files hash include iostream.h hash include math.h int main we are taking five variables int number comma a comma b comma c and d. So cout enter any three digit number the three digit number is stored in cn number. So a equal to number person 10 or modulus of 10 I have written a comment here if the user enters 1 2 3 as a three digit number modulus of the three digit number by 10 will give you the quotient as 3 and b equal to the same number that is 1 2 3 divided by 10. So we are using divided by you get only a quotient and for a we get a remainder c equal to b the value of b now here is 12 12 modulus 10. So 12 divided 12 person 10 we get 2 as a remainder and if you are using d a variable b divided by 10 12 divided by 10 the remainder will be 1. So here if you look at the four equations we need a value that a value comes to 3 and we need c value that c value comes to 2 and we need d value that comes to 1. So if a user enters three digit number that three digit number gets separated. So here cout a is equal to c is equal to and d is equal to we do not need b value. So we are not calling b value here. So the output will be enter any three digit number if the user enters 1 2 3 as a three digit number a value will be equal to 3 c value will be equal to 2 and d value will be equal to 1. So this is a program where the digits are separated from a integer. So these are the references thank you.