Sir. In 5 th statement can we use else instead of if statement.
@CodetoCareer3 жыл бұрын
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
@rohittandon23854 жыл бұрын
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..
@CodetoCareer4 жыл бұрын
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.
@harshittripathi4694 жыл бұрын
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 ?
@CodetoCareer4 жыл бұрын
Please clarify your question.
@harshittripathi4694 жыл бұрын
@@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
@CodetoCareer4 жыл бұрын
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
@rinkutapadar38814 жыл бұрын
Sir incase some of the numbers are equal then can we use of else if too?
@CodetoCareer4 жыл бұрын
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.
@rahulsinghtakuli84874 жыл бұрын
Sir, If we take a=2,b=3 and c=1then b
@CodetoCareer4 жыл бұрын
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.
@rahulsinghtakuli84874 жыл бұрын
@@CodetoCareer ok sir thank you
@ananyagupta72114 жыл бұрын
Sir if two numbers are equal then? So we should write that condition as well
@CodetoCareer4 жыл бұрын
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-iq6lb4 жыл бұрын
Can we use "else if " in this WAA in place of "if" in second or in further condition ?
@CodetoCareer4 жыл бұрын
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-iq6lb4 жыл бұрын
@@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
@dipanshupandey79524 жыл бұрын
@@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
@rinkutapadar38814 жыл бұрын
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
@CodetoCareer4 жыл бұрын
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...
@gaurabsingh93174 жыл бұрын
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 ?
@CodetoCareer4 жыл бұрын
Draw the test table and verify.
@rockerz75724 жыл бұрын
Sir,we can also do it by only using a,b,c..Isn't it sir?
@CodetoCareer4 жыл бұрын
Sure but as numbers increase that logic becomes hard to understand.