Functions (Solved Question 1)

Поділитися
Вставка
  • Опубліковано 6 жов 2024
  • C Programming & Data Structures: Functions (Solved Question 1)
    Topics discussed:
    1) Solution of GATE-2014 (CSE) problem on Functions in C.
    2) Homework problem on Functions in C.
    C Programming Lectures: goo.gl/7Eh2SS
    Follow Neso Academy on Instagram: @nesoacademy(bit.ly/2XP63OE)
    Follow me on Instagram: @jaspreetedu(bit.ly/2YX26E5)
    Contribute: www.nesoacademy...
    Memberships: bit.ly/2U7YSPI
    Books: www.nesoacademy...
    Website ► www.nesoacademy...
    Forum ► forum.nesoacade...
    Facebook ► goo.gl/Nt0PmB
    Twitter ► / nesoacademy
    Music:
    Axol x Alex Skrindo - You [NCS Release]
    #CProgrammingByNeso #CProgramming #CFunctions

КОМЕНТАРІ • 463

  • @data.practitioner
    @data.practitioner 3 роки тому +321

    Starting by incrementing from count(2)
    Count(2): 110110011__ itr0
    Count(3): 001101100__itr1
    Count(4): 000011011__itr2
    Count(5): 000000110__itr3
    Count(6): 000000001__itr4
    Count(7): 000000000__itr5
    After count(7) we get out of the loop.

  • @lalit2926
    @lalit2926 4 роки тому +270

    I am too late to watch this series but really this is best series for learning c and data structures....

    • @Dnsx_plus
      @Dnsx_plus 4 роки тому +1

      same

    • @foodmonk2292
      @foodmonk2292 4 роки тому +12

      it's never too late....BETTER LATE THAN NEVER.....starting to learn and progressing till this video is a great step...keep going...keep growing

    • @sirikisrinivasarao7994
      @sirikisrinivasarao7994 4 роки тому

      Yes bro... I want this video playlist to come in first after search.... S

    • @Jkt61205
      @Jkt61205 4 роки тому +1

      @@foodmonk2292 That's really an inspirational line bro

    • @sandippramanik5733
      @sandippramanik5733 3 роки тому

      @@foodmonk2292 True!

  • @nareshsachin7967
    @nareshsachin7967 3 роки тому +34

    lot of years im search a good tutorial for c but now i find a gold tutorial...super presentation and simple and quality examples

  • @IntradayWithShahid
    @IntradayWithShahid 5 років тому +233

    the answer is 7, as the count starts from 2 and the loop terminates after 5 iteration so 5+2=7.

  • @nforme7826
    @nforme7826 3 роки тому +9

    Here num is 435 (110110011) and count=2, if we shift right the number like
    001101100(3) ,here 3 after count (2 )give that, for understanding
    Similarly,
    000011011(4)
    000000110(5)
    000000001(6)
    000000000(7)
    After counting it gives 7 if we count after 2 and another simple way is 2+5=7.

  • @shreyassakriofficial
    @shreyassakriofficial 3 роки тому +13

    I have a little bit different approach. As it is a right shift that also we have to do 2 times per iteration so as discussed in previous lectures in right shift we divide no. By
    2^(no. Of bits to right shift)
    so here no. Of bits to shift is 2 so we will divide by 2^2 i.e. by 4. So when we count the iteration along with dividing no. The loop will terminated at 5th iteration as at 5th iteration the value i.e. the no. Will be 0 after dividing. So the final answer is 5+2 = 7. i.e. count =7

  • @megaraina8542
    @megaraina8542 3 роки тому +16

    Value of count is 7.And the loop terminates after 5 iterations. Initially the value of count is 2 and after 5 iterations it will be 5+2=7.

  • @vishwajeetkumar3636
    @vishwajeetkumar3636 4 роки тому +27

    For the loop to terminate :-
    (435/4^x) 4^x>435 => x=5.
    And since count is initiated with 2 , hence final o/p - 2+5 = 7.

    • @debjyotisarkar9578
      @debjyotisarkar9578 Рік тому +2

      Someone explain this pls?

    • @yashbindal9443
      @yashbindal9443 Рік тому

      let me explain u
      we take the value the give num and divide it by 2*2^n (first 2 is no. of swifting we are doing ,then net 2 is poissible output that is 0and1 power x which is iteration) smaller then 1 because we need to make the binary number zero which is less then 1@@debjyotisarkar9578

    • @dineshkiran987
      @dineshkiran987 3 місяці тому

      Bro explain it pls

  • @ChintanDhokai
    @ChintanDhokai 4 роки тому +6

    435= 110110011 c=2
    //right shift 2
    num=001101100 c=3
    num= 000011011 c=4
    num=000000110 c=5
    num=000000001 c=6
    num=000000000 c=7
    Ans= 7

  • @mohamedkanu66
    @mohamedkanu66 4 роки тому +22

    I got 7 for the count: 5 loop iterations for the shifts plus the initial 2 of count.

  • @DeepakThakurEntrepreneur
    @DeepakThakurEntrepreneur 3 роки тому +17

    Count = 2 (Initial Value)
    Count = 7 (Final Value)
    Answer is Count = 7

  • @Aabara_ka_dabara
    @Aabara_ka_dabara Рік тому +4

    1. 435/4 = 108; count=3
    2. 108/4 = 27; count=4
    3. 27/4 = 6; count=5
    4. 6/4 = 0; count=6 1/4=0 count=7 (final answer)

  • @Ankit-zi3yf
    @Ankit-zi3yf Рік тому +5

    He should be a private tutor for c he deserves even more i prefer to watch his videos rather than other hindi programming videos

  • @kishors8200
    @kishors8200 4 роки тому +11

    It is really useful for my gate preparation thank you sir

  • @theprofessorhetsron6713
    @theprofessorhetsron6713 4 роки тому +14

    The Answer is 7
    Thanks sir for your effort

  • @tulakchowdhury4906
    @tulakchowdhury4906 3 роки тому +7

    7
    is the value returned by the function

  • @srinjaydas9144
    @srinjaydas9144 3 роки тому +4

    When count = 7 num contains 0 value.So the condition became false and we came outside of the loop and return the value of count which is 7.So 7 is the right ans.

  • @shreedharchavan7033
    @shreedharchavan7033 3 роки тому +7

    I think it can be done with the shortcut formula you told in previous videos i.e. in right shift we divide the given number by 2^number

    • @sanjana6931
      @sanjana6931 Рік тому

      so i ain't the only one who did it that way!

  • @vishalmishra9933
    @vishalmishra9933 3 роки тому +5

    Thanks a lot to neso academy,
    For giving eacha and every concept clear as water

  • @ArunSingh-lb7qy
    @ArunSingh-lb7qy 5 років тому +12

    7. Because, now every time >> shift num by 2 bits,so num becomes num/4 each time, and 5 time loop, will make count =2+5=7.

    • @adityaband6919
      @adityaband6919 5 років тому +2

      now likes are also 7

    • @gaash313
      @gaash313 5 років тому +2

      @@adityaband6919 i broke it dear now it is 8 ....hahahah

    • @gaash313
      @gaash313 5 років тому

      but what if the count value was intialised with 0. ?

    • @adityaband6919
      @adityaband6919 5 років тому

      4

    • @adityaband6919
      @adityaband6919 5 років тому

      5

  • @pankajkumarbarman765
    @pankajkumarbarman765 5 років тому +6

    Ans in 7 sir bcz 435 in binary 110110011 and given that shifting by 2 when count is 2 the while loop will terminate after 5th iteration (the value of num is then num =000000000) and the Value of count returns is 5+2=7 ans..

  • @Softwareengineeringdev
    @Softwareengineeringdev 6 років тому +8

    You are very good teacher

  • @chandrakishorsingh9779
    @chandrakishorsingh9779 4 роки тому +3

    The value returned by func(435) is 7. (At Iter 5 we got num=0, so 5+2=7)

  • @RohitSharma-oy7id
    @RohitSharma-oy7id 5 років тому +25

    count = 7.

  • @shamlikayastha9765
    @shamlikayastha9765 2 роки тому +3

    The answer is 7. Thanks sir for your wonderful explanation.

  • @Codality
    @Codality 3 роки тому +7

    Thx Neso Academy
    Such a great Question as usual
    The answer is 7

  • @aseefraza2960
    @aseefraza2960 6 років тому +13

    loved and enjoyed a lot, eagerly waiting for the next one and much excited for data structure lectures

    • @ganavin3423
      @ganavin3423 4 роки тому +1

      Excuse me I have a doubt about 1question that num>>=1...in this why we use =operator .... it is left shift right ..then why we use =operator.

    • @ganavin3423
      @ganavin3423 4 роки тому +3

      @@saisumanth2289 thank u bro,now i am realised that it is a compound assignment. thank u for ur replied message.

  • @NikhilKumar-ev2ml
    @NikhilKumar-ev2ml 3 роки тому +4

    the value returned by func(435) is 7

  • @sharvilsopal416
    @sharvilsopal416 3 роки тому +4

    Thank you for this series. It really helped me a lot.

  • @ShivamKumar-ie1je
    @ShivamKumar-ie1je 3 роки тому +1

    Ans is 7.
    #include
    int fun(int a){
    int count=2;
    while(a){
    count++;
    a>>=2;
    }
    return count;
    }
    int main(){
    int a;
    a=435;
    fun(a);
    printf("the value of a: %d
    ",fun(a));
    return 0;
    }

  • @tehuanmelo
    @tehuanmelo 2 роки тому

    The variable count will be iterated five times, so the final value of count is 7. Best content ever!!!!

  • @sasidharan4460
    @sasidharan4460 2 роки тому +1

    Instead of doing it BIT by BIT, We can just use this this rule, We know that when we right shift a number by any number, Say 435>>1 = 217, which we can calculate by 435/2^1, By doing it again and again in calculator until it reaches 0, we can calculate the number of iterations to make that value to 0, we can find the answer I guess ?. Correct me If I am wrong peace ✌️.

  • @sagarraj4521
    @sagarraj4521 6 років тому +14

    7--hmwrk answer

  • @Ronitbaniya
    @Ronitbaniya 3 роки тому +2

    Hello sir ia am a starter of diploma in engineering college and i am felling greate to learn here
    Bither way the answer is 7.

  • @gauravdev5884
    @gauravdev5884 2 роки тому +1

    The answer to the homework is 7. But how to remember the bit representation of such a large number like 435. Do the question contains the bitwise representation of the given number?

  • @RohitSaini-pk9ir
    @RohitSaini-pk9ir 5 років тому +7

    7 in answer bez we shift count 5 times so 2+5 = 7.

  • @rakeshkumarsm6872
    @rakeshkumarsm6872 5 років тому +18

    SIR when you will upload the lecturers on datastructures.

  • @vesangisaichaitanya7447
    @vesangisaichaitanya7447 4 роки тому +4

    Sir the you provided here is extremely beautiful in every way and can you please provide c++ oops concept

  • @ritikpatel7918
    @ritikpatel7918 3 роки тому +2

    There will be 5 iteration in this loop. Th value of Count will become 2+5 = 7.

  • @Rest_leave
    @Rest_leave 2 роки тому

    The answer is 8 because after integer to binary conversation we will get 11 digits number, So in 5 iterations it will remove 10 digits from no. Then 1 digit will remain for that it will iterate one more time then count could be 6 since count start from 2 so, the answer will 8.

  • @aravindreddy5246
    @aravindreddy5246 2 роки тому

    a very good you tube channel to learn c programming.

  • @mahalingpreethi1021
    @mahalingpreethi1021 3 роки тому +1

    The value returned by func(435) is 7 as count value is 7

  • @lordjadn
    @lordjadn 4 місяці тому

    Quick question on the first task, how is the count = 9 instead of 10, when it's being incremented before the shift operation?
    while(num)
    {
    count++;
    num>>= 2;
    }

  • @hhcdghjjgsdrt235
    @hhcdghjjgsdrt235 2 роки тому

    ah I did this alone. Having a civil engineering background I think Ive got so far. Thank you Neso Academy.

  • @arinjeetbairagi6704
    @arinjeetbairagi6704 5 місяців тому

    435/2² =435/4 = 108 itr 1
    Same as it's goes for 5 times untill it reached 0
    The count strats from 2
    So the final ans is
    5+2=7

  • @millenmarbun24
    @millenmarbun24 5 років тому +4

    how is the loop argument >> while(num) means while num is not equal to zero?

    • @nishaverma7788
      @nishaverma7788 3 роки тому +1

      As regarding condition of while loop we take them as true or false and all numbers other than zero are considered as true and 0 is considered as false...

  • @kondababudittakavi5288
    @kondababudittakavi5288 5 років тому +8

    In 5th iteration num become 0 and the function returns the count value 7 so the op is 7

  • @pepepacheco6199
    @pepepacheco6199 3 роки тому +1

    wouldn´t be better to write.....while(num ¡=0) instead of just while(num)??....thank you for your reply

  • @jk15NT
    @jk15NT 6 років тому +3

    Sir your videos are tha best plzz upload more

  • @_dipakwagh_
    @_dipakwagh_ 2 роки тому +1

    after count=7,while loop condition becomes false

  • @accessdenied9393
    @accessdenied9393 3 роки тому +2

    num>>1 is equivalent to num/2
    num>>2 is equivalent to num/4 (as homewok problem)
    num>>3 is equivalent to num/6
    So we kind of dividing 435 five times until num reach to 0, so the total iteration is 5, and in each iteration we increment the value of count starting from 2:
    Iteration 1
    count = 3
    num = 108 (435/4, truncating decimals because num is of type int not float or double)
    Iteration 2
    count = 4
    num = 27 (108/4)
    Iteration 3
    count = 5
    num = 6 (27/4, truncating decimals because num is of type int not float or double)
    Iteration 4
    count = 6 (6/4, truncating decimals because num is of type int not float or double)
    num = 1 (1/4, truncating decimals because num is of type int not float or double)
    Iteration 5 (last iteration)
    count = 7 (our answer)
    num = 0 (0/0, so while condition return false).
    Code: [Debug to understand!]
    int main(void)
    {
    int count = 2, num = 435;
    while(num)
    {
    count++, num>>=2;
    printf("%d
    ",count);
    printf("%d
    ", num);
    }
    printf("%d
    ",count); // 7
    return 0;
    }

  • @AtaurRahman-ft2nh
    @AtaurRahman-ft2nh 4 роки тому +2

    Value returned by func(435)=7

  • @kartikrameshchavan6662
    @kartikrameshchavan6662 2 роки тому +1

    7 is the answer.
    Thanks Sir

  • @abpokeunite3463
    @abpokeunite3463 Рік тому

    thanks a lot sir for your video lectures they are really helpfull to us thankyou very much sir

  • @RameshKumar-yk4kl
    @RameshKumar-yk4kl 5 років тому +1

    435>>=2 COUNT IS 7.
    Thank you sir.

  • @simasaha81
    @simasaha81 3 роки тому +1

    7 will be the answer. God, I am getting correct answers. So, enough for today going to sleep and have a good dream.

  • @bjp_zero
    @bjp_zero 7 місяців тому

    For left shift multiplication and for right shift division

  • @leoengy
    @leoengy 3 роки тому +2

    The answer for the second case would be 5 (iterations) if I am not mistaken.

  • @ajmalkhaniit
    @ajmalkhaniit 4 роки тому +1

    In the fifth iteration num becomes all zeros so count is 7

  • @imharishsambasivam
    @imharishsambasivam 5 років тому +1

    num / 2 power 1 .since shify by 1..

  • @avunooritagore6089
    @avunooritagore6089 6 років тому +11

    7

  • @teegalashreyaamadhury
    @teegalashreyaamadhury 3 місяці тому

    the ans is 7 iterations if count is 2 as it right shifted by 2

  • @jebuelspat213
    @jebuelspat213 5 років тому +2

    Ans : 5

  • @ajaykumar5873
    @ajaykumar5873 4 роки тому +1

    The answer comes To be 7. Is it right?

  • @PriyankaGupta-gn7ve
    @PriyankaGupta-gn7ve 2 роки тому

    C(2):110110011
    C(3):001101100
    C(4):000011011
    C(5):000000110
    C(6):000000001
    C(7):000000000
    Return value will be 7

  • @ganavin3423
    @ganavin3423 4 роки тому +1

    We hitted the like button....and subscribed also ......but ur not solving anyone's doubt......please solve ours doubt...I request u sir.. why we use =operator in num>>=1...

  • @khannasir1057
    @khannasir1057 3 роки тому

    sir made a videos on c++ i really like your's c videos

  • @Krishna_Keshri
    @Krishna_Keshri 4 роки тому +1

    Count=2+5;
    Count=7;

  • @badavathjaipal7027
    @badavathjaipal7027 2 роки тому

    The func(435)=7;after 7th count loop can't be terminated...

  • @ganavin3423
    @ganavin3423 4 роки тому +1

    Anything is wrong in my question.if you won't reply me then what is the need of doing sessions .... it's not cleared for me .... please help me sir🙏🙏🙏🙏.... Why we use=operator in num>>=1.

  • @najminakter2773
    @najminakter2773 2 місяці тому

    this program counted 2bits then running count value 5 and initial value 2 . then finally output is 2+5= 7 .

  • @Geff_115
    @Geff_115 10 місяців тому

    after count(6), value returned is 4

  • @hussainadenwala7872
    @hussainadenwala7872 3 роки тому

    in iteration 5 the num became 0 and return count will be 7

  • @JaiShriRam9251
    @JaiShriRam9251 4 роки тому +1

    Absolutely=7

  • @prajapati_23
    @prajapati_23 5 місяців тому

    Answer 1st iteration 00110110
    2nd iteration 000011011
    3rd iteration 000000110
    4th iteration 000000001
    4th iteration 000000000
    Finally count -7❤

  • @ganavin3423
    @ganavin3423 4 роки тому

    What is the need of usig = operator in num>>=1.

  • @pavanjami9241
    @pavanjami9241 6 років тому +1

    How binary number is shifting? I didn't get

  • @rahulkumbhar367
    @rahulkumbhar367 4 роки тому +1

    Answer is 7

  • @raghunathshelke6170
    @raghunathshelke6170 6 років тому +2

    7 is answer of 2 nd eg

  • @degalaashok4408
    @degalaashok4408 5 років тому

    your way of explanation is correct, but small correction i.e 435=110111101

  • @true4189
    @true4189 4 роки тому +1

    Thank u

  • @rahultheytv5347
    @rahultheytv5347 5 років тому

    1|10|11|00|11 , count =2+5=7

  • @danishparvez5813
    @danishparvez5813 4 роки тому

    Could you please help me in that:-
    #include
    void fun (int a)
    {
    if(a>0)
    {
    fun(--a);
    printf("%d",a);
    fun (--a);
    }
    }
    int main()
    {
    int i=3;
    fun (i);
    return 0;
    }

  • @TanuSoni-z8s
    @TanuSoni-z8s Рік тому

    where it is written that num isn't equal to zero

  • @marvelshorts2.o337
    @marvelshorts2.o337 Рік тому

    nice explaination sir

  • @maheshm1144
    @maheshm1144 3 роки тому

    answer is 7
    thanks for explaining

  • @TheSabarno
    @TheSabarno Рік тому

    7
    There there will be 5 iterations until while loop turns false.

  • @kartikyasrivastava1031
    @kartikyasrivastava1031 6 років тому +2

    sir please upload next unit lecture please ie array

  • @bjp_zero
    @bjp_zero 7 місяців тому

    for hw, divide by 4,So answer become 7

  • @compilerrun5516
    @compilerrun5516 4 роки тому +2

    This question is all about conversion

  • @pankajkumarray6716
    @pankajkumarray6716 6 років тому +2

    Is it 7 for homework q ?

  • @shubhamkeshri1184
    @shubhamkeshri1184 4 роки тому

    Please sir data structure pe or video upload kro....ab bas aap hi last hope ho mere liye...nd thanks for this video

  • @karatekamma8839
    @karatekamma8839 4 роки тому

    And one thing I don't understand are ">>" and ">>=" same? It would have been the same with out "=" also, then why use "=" after ">>" ??
    Without the "=" I could solve it, but it kept me thinking 🤔

    • @sushantbawiskar1345
      @sushantbawiskar1345 4 роки тому +1

      ">>" will only shift bit it won't reflect in actual number , ">>=" this is equal to number = number >> 1;

    • @karatekamma8839
      @karatekamma8839 4 роки тому

      Oh... I see 🤔
      Thanks..

  • @ganavin3423
    @ganavin3423 4 роки тому

    Please reply anything sir....when we use num>>=1 it shows error....so ...I think num>>1 is correct...,..if you won't answer for these question these doubt is always with me and it will never clarifies.... please reply soon.... It will helpful for every student of u sir....I am the begginer for this programming .. I am basically a bio student.... please help me sir..

    • @B-Aparnasai
      @B-Aparnasai 4 роки тому

      Num>>=1 is equal to num=num>>1

    • @ganavin3423
      @ganavin3423 4 роки тому

      @@B-Aparnasai thank you...now I realized that it is the assignment operator.

  • @ergoproxy3032
    @ergoproxy3032 2 роки тому

    how did we understand we have to get it out of while loop when number is 0, there is no if condition

    • @sinibs7179
      @sinibs7179 Рік тому

      0 means false , the compiles assumes it even though its not given.

  • @arjyapaul2695
    @arjyapaul2695 4 роки тому

    is this bitwise operator problem?

  • @VikasKumar-cf4ed
    @VikasKumar-cf4ed 3 роки тому

    the final count =7 bcz after 5 iteration loop terminate.

  • @rajeevKr07
    @rajeevKr07 4 роки тому +1

    How it will strike that we have to first convert it into binary plzz answer anyone

    • @pranshul..
      @pranshul.. 4 роки тому

      Previous lectures se

    • @pranshul..
      @pranshul.. 4 роки тому

      @Rohan Rathour ok

    • @pranshul..
      @pranshul.. 4 роки тому

      @Rohan Rathour lecture no. 43 under loops section 1st question
      Where he changes first time decimal to binary for right shift operator.

  • @PraveenKumar-mm4ob
    @PraveenKumar-mm4ob 6 років тому +1

    Is it a aptitude base question in gate or in some spacial branch paper?
    Please someone tell me this

    • @dhairyakatyayan9654
      @dhairyakatyayan9654 6 років тому

      Not aptitude base. Its for C programming, branch: Computer Science.

  • @himanshugupta7947
    @himanshugupta7947 5 років тому +2

    Homework answer.... 7