Special Programs in C − Binary to Decimal Conversion

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2024

ความคิดเห็น • 105

  • @boblopez7649
    @boblopez7649 ปีที่แล้ว +7

    I did this program using shift left operator(

  • @sunnygomes608
    @sunnygomes608 3 ปีที่แล้ว +22

    Best channel for computer science students so far. Thanks for making such great contents.

  • @Obama6464
    @Obama6464 2 ปีที่แล้ว +3

    Great lecture. Many ways this can be done (including using the math.h library and utilizing the pow() function) but the previous person that taught me this didn't explain why we were doing the modulus and division in a clear way. You, however, did. Thanks!

  • @-HarishkumarG
    @-HarishkumarG 3 ปีที่แล้ว +78

    Idk how am I going to survive in IT field 😭

    • @ibtissamelhammoumy9586
      @ibtissamelhammoumy9586 3 ปีที่แล้ว +7

      don't worry

    • @-HarishkumarG
      @-HarishkumarG 3 ปีที่แล้ว +3

      @@ibtissamelhammoumy9586 thanks :-)

    • @AshutoshKumar-jj6kz
      @AshutoshKumar-jj6kz 2 ปีที่แล้ว +13

      same here no logic only magic in programming

    • @nileshtayade3546
      @nileshtayade3546 2 ปีที่แล้ว +13

      Don't worry bro me bhi apke jaisa hi sochta tha lekin dhire dhire Sab samaj ate jata hai bas koshish karte rho

    • @AlameenAdeyemi
      @AlameenAdeyemi 10 หลายเดือนก่อน +2

      It's 2024,how are u doing now bro

  • @ramdayalkumawat2568
    @ramdayalkumawat2568 4 ปีที่แล้ว +15

    Sir this is so wonderful lecture

  • @mayankjadhav4509
    @mayankjadhav4509 6 ปีที่แล้ว +8

    Thank you so much sir...today i understood the program and Sir please post binary to octal and hexadecimal too...

  • @madhavikatta7346
    @madhavikatta7346 5 ปีที่แล้ว +35

    Thank you so much
    Sir one day I will be in the good position definitely on that day I will sponsor huge amount money to our channel

  • @nikhilsingh7666
    @nikhilsingh7666 3 ปีที่แล้ว +3

    nice lecture I got a hint for the CodeChef challenge thanks

  • @rudrachakraborty7896
    @rudrachakraborty7896 ปีที่แล้ว

    Thank you, sir. This really helped me with my paper 1 programming practice. From London

  • @dambro3312
    @dambro3312 ปีที่แล้ว +3

    i did it using biwise operators! it worked! ig
    int bin_dec()
    {
    int bin,dec;
    scanf("%d",&bin);
    for (int shift; bin!=0; shift++)
    {
    int r = bin%10;
    dec = (r

  • @roshnimishra3454
    @roshnimishra3454 6 ปีที่แล้ว +5

    nice one
    made the concept very clear
    very helpful

  • @avishekkbhatta
    @avishekkbhatta ปีที่แล้ว

    best channel.................................................

  • @ashokkumark2243
    @ashokkumark2243 4 ปีที่แล้ว +9

    We store hex value starts with 0x, and octal starts with 0 and decimal as it is in the integer type..
    How do we store a binary number in the integer type??
    Here why do we convert a decimal number to decimal again??
    Where actually is it useful??
    Can someone please explain??

  • @aakashmudigonda3375
    @aakashmudigonda3375 4 ปีที่แล้ว +2

    if anyone of you guys, didn't understand the above code, this my own code, which I made from a simpler logic....
    #include
    #include
    int main(void) {
    // example : convert 1 0 0 1 to decimal
    // [1]*2^(3)+ [0]*2^(2)+ [0]*2^(1) + [1]*2^(0)
    printf("enter a binary number : ");
    int n;
    scanf("%d",&n);
    int temp = n;
    int rem = 0;
    int result = 0;
    int count = 0;
    int last_num= 0;
    while (temp!=0) {
    temp = temp/10;
    count++;
    }
    temp = n;
    for (int i = 0; i

  • @Deepthi_Chowdary5321
    @Deepthi_Chowdary5321 ปีที่แล้ว +1

    Sir u make more series on only focusing on problem..

  • @arnoldgatchalian8643
    @arnoldgatchalian8643 3 ปีที่แล้ว +1

    Thank you I've learned a lot from you

  • @itsbayahmed
    @itsbayahmed ปีที่แล้ว +3

    Here is another solution to this problem:
    #include
    #include
    int main()
    {
    long long int number, num, result, n;
    printf("Please Enter the Binary number: ");
    scanf("%lld",&number);
    result = 0;
    n =0;
    num = number;
    while(num != 0)
    {
    result = result + (num % 10) * pow(2,n) ;
    n++;
    num = num / 10;
    }
    printf("%lld in decimal is %lld", number, result);
    return (0);
    }

  • @shreya9275
    @shreya9275 2 ปีที่แล้ว

    Absolutely Brilliant explanation

  • @HuynhThanhThuan
    @HuynhThanhThuan 4 ปีที่แล้ว +1

    Very easy to understanding, thank you dear Sir.

  • @zoreladreanrivera9822
    @zoreladreanrivera9822 7 หลายเดือนก่อน

    #include
    #include
    int main ( void ) {
    int binary;
    printf ( "Enter binary number: " );
    scanf ( "%d", &binary );
    int counter1 = 0;
    int A = binary;
    while ( A != 0 ) {
    A /= 10;
    counter1++;
    }
    int remainder = 0;
    int power = 0;
    int sum = 0;
    for ( int counter2 = 0; counter2 < counter1; counter2++ ) {
    remainder = binary % 10;
    power = ( pow ( ( remainder * 2 ), counter2 ) ) * remainder ;
    sum += power;
    binary /= 10;
    }
    printf ( "Decimal Equivalent = %d", sum );
    return 0;
    }

  • @nishabhandari5190
    @nishabhandari5190 3 หลายเดือนก่อน

    Thank you so much professor

  • @vinaykamble162
    @vinaykamble162 3 ปีที่แล้ว +2

    It's amazing explanation ❤️

  • @YashDEVELOPER12
    @YashDEVELOPER12 4 ปีที่แล้ว +1

    Very beautiful explanation sir.. u r amazing 🙏

  • @shikhajamwal4709
    @shikhajamwal4709 3 ปีที่แล้ว

    u have explained it very well

  • @mdmuquimakhter5145
    @mdmuquimakhter5145 2 ปีที่แล้ว

    awesomely explained

  • @gayathripvl8184
    @gayathripvl8184 3 ปีที่แล้ว

    sir you are doing very great job

  • @kapiljetwani3540
    @kapiljetwani3540 3 ปีที่แล้ว +1

    thank u for such a nice explaination!

  • @andistheinforitbutso7513
    @andistheinforitbutso7513 2 ปีที่แล้ว

    All hail 🙌 Neso Academy

  • @beauty-ez8ox
    @beauty-ez8ox ปีที่แล้ว

    Wow 💜💜💜
    ... So nicely explained

  • @sahilarora7186
    @sahilarora7186 2 ปีที่แล้ว

    very nice explanation thank you sir

  • @manojraut9630
    @manojraut9630 2 ปีที่แล้ว

    You are Best.👏

  • @HelderKJPedro
    @HelderKJPedro 2 ปีที่แล้ว

    Thank you so much 🙏🏽

  • @tumutarun5157
    @tumutarun5157 6 ปีที่แล้ว +3

    Upload all videos in c language for learners

  • @gopichowdary2040
    @gopichowdary2040 6 ปีที่แล้ว +1

    Sir please upload daily one video like circuit theory videos are being uploaded

  • @sowmyapg3381
    @sowmyapg3381 3 ปีที่แล้ว

    Understood thankyou

  • @Hichamb04
    @Hichamb04 2 ปีที่แล้ว

    thanks bro that was so helpful .

  • @dheerajk7
    @dheerajk7 3 ปีที่แล้ว

    Thankyou so much sir

  • @poojajagtap6356
    @poojajagtap6356 3 ปีที่แล้ว

    thanks sir

  • @ArunChoudhary-lr7rp
    @ArunChoudhary-lr7rp 11 หลายเดือนก่อน

    Outstanding

  • @mousex5532
    @mousex5532 6 ปีที่แล้ว

    thankyou

  • @jagugamit150
    @jagugamit150 3 ปีที่แล้ว

    I am getting error
    Input :- 0011
    Output :- 9
    Expected output should : - 3

  • @basics698
    @basics698 6 ปีที่แล้ว

    Please make videos on control systems.

  • @true4189
    @true4189 4 ปีที่แล้ว

    Thank u

  • @mdathar1947
    @mdathar1947 2 ปีที่แล้ว

    Sir pls cover the corners case also...

    • @mdathar1947
      @mdathar1947 2 ปีที่แล้ว

      If I enter a binary contain more than 10 digit ....2. if I enter for eq-101101010101
      Will your program work in these 2cases??

  • @5303sandeep
    @5303sandeep 5 ปีที่แล้ว +2

    Here is the code for invalid input for eg:- 1201(which is not binary)
    #include
    int main()
    {
    //Initialization and user input
    int b,rem,decimal = 0,w = 1,num,c=0;//w = weight,b = binary
    printf("Enter binary number to covert to decimal
    ");
    scanf("%d",&b);
    num = b;
    //Binary to Decimal Conversion
    while(num!=0)
    {
    rem = num%10;
    if(rem>1)
    {
    printf("Invalid input:Input contains number other than 0 and 1
    Please enter a valid input
    ");
    c = 1;
    break;
    }
    else
    {
    decimal = decimal + rem*w;
    num = num/10;
    w = w*2;
    }
    }
    //Printing result
    if(c==0)
    printf("%d is the decimal conversion of binary %d",decimal,b);
    }

  • @gamingcousinstamil
    @gamingcousinstamil 2 ปีที่แล้ว

    Super sir

  • @namraarif100
    @namraarif100 4 ปีที่แล้ว

    Very helpful video sir
    But you did not initialize rem in start. Will it not a problem to run this program?

  • @hatemali4220
    @hatemali4220 10 หลายเดือนก่อน

    Enta gamed strong

  • @Khadra2024
    @Khadra2024 3 ปีที่แล้ว +1

    if i want to check if the number have only 1 and 0 how can i do that?
    if it has other number, send error message :(

  • @ColorsOfLife114
    @ColorsOfLife114 2 ปีที่แล้ว

    As the weight of first digit from right side is zero then why we take it 1???

  • @ramanandasharma9214
    @ramanandasharma9214 2 ปีที่แล้ว

    please give the flowchart and algorithm for this

  • @sinchana9358
    @sinchana9358 4 ปีที่แล้ว +1

    Plzz make a vedio on how to convert decimal to binary plzz sir🙏🙏

    • @archipalexandru-ioan5898
      @archipalexandru-ioan5898 3 ปีที่แล้ว

      #include
      int main()
      {
      int var=65;
      int i;
      int bit;
      for(i=8;i>0;i--)
      {
      bit=(var>>i-1) &1;
      printf("%d",bit);
      }
      }

    • @archipalexandru-ioan5898
      @archipalexandru-ioan5898 3 ปีที่แล้ว

      here you have,65 is the number converted to binary,the for its from 8 to 1,so you can store the bits from left to right

  • @ashishsinha8893
    @ashishsinha8893 6 ปีที่แล้ว

    Sir u r going to upload videos in daily basis or not ???????

  • @bkrulz1280
    @bkrulz1280 4 ปีที่แล้ว +1

    How to write it in a recursive function

  • @Ginihiniikk986
    @Ginihiniikk986 4 ปีที่แล้ว +1

    what is weight??

    • @rameshv2762
      @rameshv2762 4 ปีที่แล้ว

      It's a decimal value of number at certain position in a binary number.. Wn you travel from Lsb to msb... The value changes frm 2 to 2^n ..🙂

  • @jagadeeshwaran1512
    @jagadeeshwaran1512 3 ปีที่แล้ว

    I just added a feature to this program, i.e., to display a error message when a non binary number is entered.

  • @AdityaGupta-pl1ss
    @AdityaGupta-pl1ss 3 ปีที่แล้ว

    What is the meaning of Weight here

  • @minku2108
    @minku2108 2 ปีที่แล้ว

    Program for binary to hexa?

  • @muskanustad3834
    @muskanustad3834 2 ปีที่แล้ว

    What about negative binary numbers🙄?

  • @songoku2013
    @songoku2013 3 ปีที่แล้ว

    But what if the input is '101.011' or any other fractional binary number ? How to program that ?

  • @avinashyadav8598
    @avinashyadav8598 4 ปีที่แล้ว +1

    Program dont work for 0011

  • @TheJoker-xw5pd
    @TheJoker-xw5pd 3 ปีที่แล้ว

    Bro agar hum koi or number add kare like as jo binary me na ho to code invalid ana chaiye to kaise hoga

  • @muhammedshafeek3905
    @muhammedshafeek3905 3 ปีที่แล้ว

    In code blocks if I use space in print"%d " after %d before " once I build the code code block become stuck how I solve this

  • @nazmashaik2558
    @nazmashaik2558 5 ปีที่แล้ว

    Sir I execute this program but the out put is not correct there is so different.what can I do

  • @goldendragon5371
    @goldendragon5371 5 ปีที่แล้ว

    Binary to octal please bro..... >.

  • @amudhapi6492
    @amudhapi6492 4 ปีที่แล้ว

    Why weight=1 and what r the purpose for use weight plz reply me

    • @arunjithajith7958
      @arunjithajith7958 3 ปีที่แล้ว +1

      Weight is base
      Initially base value will be 1 so we initialise weight with 1

    • @amudhapi6492
      @amudhapi6492 3 ปีที่แล้ว

      @@arunjithajith7958 Thank u Arunjith

  • @Naveen-n3p1i
    @Naveen-n3p1i 10 วันที่ผ่านมา

    Is not working all values🤷‍♂🤷‍♂🤷‍♂🤷‍♂

  • @ic4r023
    @ic4r023 4 ปีที่แล้ว +2

    Very good video. But I replicated the exact same code in Dart (doing the syntax changes) and the result was different! It gave me 11.24999999.
    There is my code in Dart:
    num binary = 1001;
    num decimal = 0;
    var base = 1;
    void main (){
    while(binary != 0){
    var rem = binary % 10;
    decimal = decimal + rem*base;
    binary = binary / 10;
    base = base*2;
    }
    print(decimal);
    }
    Can someone please explain to me where I'm wrong?

  • @satyanarayanakoppuravuri161
    @satyanarayanakoppuravuri161 5 ปีที่แล้ว

    if we give binary as 0000 ?

    • @krank3869
      @krank3869 5 ปีที่แล้ว +1

      it's gonna return 0.

  • @donpilarsuarezgudino5160
    @donpilarsuarezgudino5160 3 ปีที่แล้ว

    This code don't work in Python... Any help??

  • @reimannintegrability
    @reimannintegrability ปีที่แล้ว

    😢

  • @sharuhasans9417
    @sharuhasans9417 5 ปีที่แล้ว

    How 1 divd by 10 remainder will b 1

    • @Vinay_Yarramsetty
      @Vinay_Yarramsetty 4 ปีที่แล้ว +1

      10) 1 (0
      0
      -------------
      1
      I think this is the way
      But not like
      1) 10 (10

    • @gourabdutta7086
      @gourabdutta7086 2 ปีที่แล้ว

      10*0=0..so remainder will be 1

  • @harshitha6160
    @harshitha6160 6 ปีที่แล้ว +1

    First view, and first comment

  • @Kartik001arts
    @Kartik001arts 2 ปีที่แล้ว

    Codes don't get executed which you teach in the window.....

  • @redricblue8790
    @redricblue8790 2 ปีที่แล้ว

    Why did I choose software engineering? It's fucking hard

    • @aldolhitlercondensation1363
      @aldolhitlercondensation1363 2 ปีที่แล้ว

      Hey I'm sorry you feel this way. This is actually fun if you get the concept, let me try and help.
      So the decimal number system (the system we naturally use) is very similar to the binary number system. Figuring out this key difference is all the logic you need to write the code.
      So for instance, to find the value of any decimal number we're actually multiplying each constituent digit with increasing powers of 10
      for eg: 139 = 1*10^2 + 3*10^1 + 9*10^0 . It's just that we do this so naturally so that we don't usually give it a second thought. The decimal number system supports the digits [0-9]
      Comparing this with the very similar BINARY number system which just supports the digits 0 & 1, to get the value of a binary number we're simply multiplying the digit (bit) at each position with increasing powers of 2!
      for eg: 1011 represents 1 * 2^3 + 0 * 2^2 + 1 * 2^1 + 1 * 2^0 i.e the digit 11 in decimal.
      This is all the software engineering aspect there is. The rest is basically figuring out the fundamentals of any language to execute this.
      In fact, I would urge that you write your own code once you know this logic without referring the video. All you need to do that is
      i) knowledge of how to extract bit by bit from a given input
      ii) how to compute powers
      iii) how to use loops and conditional statements.
      Googling each of these gives you a clear idea of what they do.
      I hope i was able to help

    • @Deepthi_Chowdary5321
      @Deepthi_Chowdary5321 ปีที่แล้ว

      Don't worry yar. All will be good.. Better luck