WK5 - 38 Algorithm Smallest of three Numbers

  Рет қаралды 9,949

Code to Career

Code to Career

Күн бұрын

Пікірлер: 26
@theraikwal
@theraikwal 3 жыл бұрын
Sir. In 5 th statement can we use else instead of if statement.
@CodetoCareer
@CodetoCareer 3 жыл бұрын
Make the change. Test with these input values and let me know the output by constructing a test table. a = 1 b = 2 c = 3
@rohittandon2385
@rohittandon2385 4 жыл бұрын
Sir about these algorithms, is it important to draw and show the test table too because see i personally have done java n c++ in 10th and 12th respectively. So, i have an idea how this works. Can i test my logic in my mind or aside and just not show it? Obviously this is bcz you want us to learn how to test, thats why am asking..
@CodetoCareer
@CodetoCareer 4 жыл бұрын
When code is small it makes not much of a difference. But once you come to LOOPS without test table there is no way to know the correctness of the logic. Except for the simplest of the sequential logic problems where it may be given a pass. For decision making and loop problems test table is wonderful tool to prove the correctness of your code. The test table also helps the teacher quickly evaluate your code in practical exams. The reason is clearly not to learn how to TEST. The reason is to show that your code works correctly.
@harshittripathi469
@harshittripathi469 4 жыл бұрын
sir is this algorithm is value depended means the value of a,b,c which we have assumed ? we can write it another form depend on values ?
@CodetoCareer
@CodetoCareer 4 жыл бұрын
Please clarify your question.
@harshittripathi469
@harshittripathi469 4 жыл бұрын
@@CodetoCareer SIR what if value of a is smaller than b , means this algorithm is dependent on values what we have assumed but what if we take a as 2 and b as 5 and c as 1. so we have to use else if also, because we have assumed the values of a b c which can be anything because it was not provided in question
@CodetoCareer
@CodetoCareer 4 жыл бұрын
Draw a test table and check with any of these values. The result shall always be correct. 1 2 3 3 1 2 2 3 1
@rinkutapadar3881
@rinkutapadar3881 4 жыл бұрын
Sir incase some of the numbers are equal then can we use of else if too?
@CodetoCareer
@CodetoCareer 4 жыл бұрын
If some of the numbers are equal what is explained shall work. But if all are equal then there is actually no smallest among them. The message should be all numbers are equal. This is very easily done in programming that's why to keep it simple I have said unequal numbers.
@rahulsinghtakuli8487
@rahulsinghtakuli8487 4 жыл бұрын
Sir, If we take a=2,b=3 and c=1then b
@CodetoCareer
@CodetoCareer 4 жыл бұрын
Draw the test table as shown in the example. Go through the logic. If that condition is false nothing changes in small. Then in the next step c shall be the new small.
@rahulsinghtakuli8487
@rahulsinghtakuli8487 4 жыл бұрын
@@CodetoCareer ok sir thank you
@ananyagupta7211
@ananyagupta7211 4 жыл бұрын
Sir if two numbers are equal then? So we should write that condition as well
@CodetoCareer
@CodetoCareer 4 жыл бұрын
For now assume all are unequal. In C programming it is much easier to deal with it. We shall take care of it then.
@AYUSHKUMAR-iq6lb
@AYUSHKUMAR-iq6lb 4 жыл бұрын
Can we use "else if " in this WAA in place of "if" in second or in further condition ?
@CodetoCareer
@CodetoCareer 4 жыл бұрын
You shall get a answer to your questions by doing a dry run or TEST run with the following data set... A B C 10 5 3 Tell me what the code prints as smallest number after this data is tested against your suggestion.
@AYUSHKUMAR-iq6lb
@AYUSHKUMAR-iq6lb 4 жыл бұрын
@@CodetoCareer ok sir , as i am thinking if we use "else if " then we have to change a algorithms according to that but i will try to make algorithm using "else if " and try to make difference in both the condition
@dipanshupandey7952
@dipanshupandey7952 4 жыл бұрын
@@CodetoCareer sir it means that we only use else statement when the if one is false.but in the given example all conditions are true so we will be using only if
@rinkutapadar3881
@rinkutapadar3881 4 жыл бұрын
Sir can't i use if else if loop for this program? Without assuming any smallest number? I tried the test table n it worked
@CodetoCareer
@CodetoCareer 4 жыл бұрын
if else is a decision making statement not a LOOP. The code uses if statement only NO ELSE. If you do using if else or if else if else, you shall not get the correct results in all the cases. Try this sample data set and see the output. -1 0 1 0 -1 1 1 0 -1 You just were lucky that it worked on a given data set. It shall not produce the correct result is all cases. Though it is possible you may have used the approach mentioned in most textbooks and other authors where they combine conditions using the AND word. The problem with that approach it that it can be difficult to understand once the number of variables exceeds 3. Post you solution and I shall get back...
@gaurabsingh9317
@gaurabsingh9317 4 жыл бұрын
Sir it seems like we are swaping the no .let a=-1,b=2,c=3.then according to algorithm it will show c is small .? So what i think 🤔 is correct or wrong ?
@CodetoCareer
@CodetoCareer 4 жыл бұрын
Draw the test table and verify.
@rockerz7572
@rockerz7572 4 жыл бұрын
Sir,we can also do it by only using a,b,c..Isn't it sir?
@CodetoCareer
@CodetoCareer 4 жыл бұрын
Sure but as numbers increase that logic becomes hard to understand.
@rockerz7572
@rockerz7572 4 жыл бұрын
@@CodetoCareer SIR YES SIR
WK5 - 39 Algorithm Leap Year
7:55
Code to Career
Рет қаралды 10 М.
Flow Chart For find Largest Number among three number
5:43
Ayush Sharma
Рет қаралды 72 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
Algorithm to find sum of first n natural numbers. Draw Flowchart for it.
11:20
The hidden beauty of the A* algorithm
19:22
Polylog
Рет қаралды 915 М.
1. Algorithms and Computation
45:39
MIT OpenCourseWare
Рет қаралды 1,5 МЛН
Guess The Egyptian
34:57
Dose of Emirates
Рет қаралды 355 М.
If you're ambitious but lazy, please watch this video...
12:57
Mark Tilbury
Рет қаралды 271 М.
C, C++ Program to Find Smallest of three numbers
3:42
Programming Tutorials
Рет қаралды 25 М.