Special Programs in C − Binary to Decimal Conversion

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ม.ค. 2025

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

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

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

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

    I did this program using shift left operator(

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

    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!

  • @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 6 ปีที่แล้ว +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

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

    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 ปีที่แล้ว +14

      same here no logic only magic in programming

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

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

    • @iatomic_1
      @iatomic_1 11 หลายเดือนก่อน +2

      It's 2024,how are u doing now bro

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

    nice one
    made the concept very clear
    very helpful

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

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

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

    nice lecture I got a hint for the CodeChef challenge thanks

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

    Wow 💜💜💜
    ... So nicely explained

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

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

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

    Thank you I've learned a lot from you

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

    It's amazing explanation ❤️

  • @dambro3312
    @dambro3312 2 ปีที่แล้ว +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

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

    Very beautiful explanation sir.. u r amazing 🙏

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

    You are Best.👏

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

    Very easy to understanding, thank you dear Sir.

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

    All hail 🙌 Neso Academy

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

    Absolutely Brilliant explanation

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

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

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

    thank u for such a nice explaination!

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

    Thank you so much professor

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

    Thank you so much 🙏🏽

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

    awesomely explained

  • @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??

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

    thanks bro that was so helpful .

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

    u have explained it very well

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

    sir you are doing very great job

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

    very nice explanation thank you sir

  • @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

  • @ArunChoudhary-lr7rp
    @ArunChoudhary-lr7rp ปีที่แล้ว

    Outstanding

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

    Understood thankyou

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

    Thankyou so much sir

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

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

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

    #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;
    }

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

    Upload all videos in c language for learners

  • @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);
    }

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

    Super sir

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

    thanks sir

  • @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 :(

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

    Thank u

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

    Enta gamed strong

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

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

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

    Sir pls cover the corners case also...

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

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

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

    Please make videos on control systems.

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

    thankyou

  • @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

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

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

  • @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

  • @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

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

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

  • @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);
    }

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

    How to write it in a recursive function

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

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

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

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

    • @KaMaL-_-016
      @KaMaL-_-016 18 วันที่ผ่านมา

      2^0 = 1

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

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

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

    Program for binary to hexa?

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

    What is the meaning of Weight here

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

    please give the flowchart and algorithm for this

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

    What about negative binary numbers🙄?

  • @Ginihiniikk986
    @Ginihiniikk986 5 ปีที่แล้ว +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 ..🙂

  • @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?

  • @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.

  • @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

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

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

  • @Naveen-n3p1i
    @Naveen-n3p1i หลายเดือนก่อน

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

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

    Program dont work for 0011

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

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

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

    First view, and first comment

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

    if we give binary as 0000 ?

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

      it's gonna return 0.

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

    😢

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

    How 1 divd by 10 remainder will b 1

    • @Vinay_Yarramsetty
      @Vinay_Yarramsetty 5 ปีที่แล้ว +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

  • @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

  • @Jahnavikota914
    @Jahnavikota914 10 วันที่ผ่านมา +1

    Thank you sir❤