C Programming | Networking | General Computer | Exam Questions & Answers | How To Article | Tips & Tricks | PHP Programming | Source Code | PHP | MySql | Pointer | Operators | Constant | Variable | Keyboard | Algorithm | Flowchart | Storage Classes | Function | Ms-Excel, basic of Excel, learn Excel, Online tutorial of Ms-Excel, Excel step by step learn,
wow great! its help me thanx
please I want to understand wht does this mean n1=n1+n2; n2=n1-n2; n1=n1-n2;
@Khaoula Ali,It is swapping of number if second number is greater then first number.For example:num1 = 5num2 = 10As our condition: num2 > num1 is True so,n1=n1+n2 = 5+10 = 15 ; //now n1 value = 15n2=n1-n2 = 15-10 = 5 ; //now n2 value = 5n1=n1-n2 = 15-5 = 10 ; //now n1 value = 10So you can see that n1 and n2 value has been swap.
That means swapping(interchange) the values for examplen1=45n2=65 condition is n2>n1 n1=n1+n2 -> n1=45+65=110 // now n1=110 n2=n1-n2 -> n2=110-65=45 // now n2=45 n1=n1-n2 -> n1=110-45=65 // now n1=65finally n1=65 , n2=45
n1 65 n2 45 then how the condition satisfie n2>n1 tell me fast
@Swathi,We can omit the if condition.The if condition ensure that first number (n1) should be always be bigger to second number.In this program if condition used because user can understand what is happening during the compiling.If you omit the "if condition" , it happens in do...while loop.
and wht is rem ?
@Khaoula Ali,"rem" is a variable that represent the reminder.For example:rem = 14%5 = 4
cant we write this program with while loop?
@Swathi Kankata,We can set the condition according to required program and responsive result.If you change the condition in above "finding the GCD or HCF" program n1>n2 rather than n2>n1Then you should make this algorithm, set all related condition, cross check with putting the dummy data and run the program.Hope its helpful.
n1>n2 then wat is the answer