Special Programs in C− Check If The Number Is Armstrong Number

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

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

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

    I was always looking for explanations behind such programs, a source from where I can learn the concepts, and I finally found this channel, I really needed this as I use to feel alienated in computer science, but this already made me excited about everything related to computer science again, can't thank enough!! ♥️🙏🏾

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

      i know Im randomly asking but does someone know a trick to get back into an Instagram account??
      I somehow lost my account password. I appreciate any tips you can give me!

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

      alternative
      int main() {
      int num,count=0,sum=0,rem,result=0;
      printf("enter a number
      ");
      scanf("%d",&num);
      int kela=num;
      int lela=num;
      while(num!=0){
      num=num/10;
      count++;
      }
      while(lela!=0){
      rem=lela%10;
      sum=sum+pow(rem,count);
      lela/=10;
      }
      if(kela==sum) {
      printf("its a armstrong number i.e %d",kela);
      }
      else{
      printf("its not a armstrong number coz %d",sum);
      }
      return 0;
      }

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

      Are u btech cse student?

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

    its amazing and very interesting to learn c programming from neso academy

  • @dancelifevarsha4109
    @dancelifevarsha4109 4 ปีที่แล้ว +6

    Wow.... Thank you so so much.. Concept is clearly explained.. Voice is very soothing.. Lots of love ❤❤❤❤❤❤.. Thank you so much 😇😇

  • @ProgrammingAndCS-ko1ww
    @ProgrammingAndCS-ko1ww 11 หลายเดือนก่อน +1

    i love you explanation each step i learn programming for while many tutorial go fast without clear explanation like this make me exhaust to figure it out what going on in every line of code, now i'm back to go to basic and found this channel love it

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

    Using
    digits = (int) log(10) + 1 //digits is count in this case

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

    that was really a presentation which cleared my concept on what Armstrong number is and what algorithm should be used to find a number whether is it armstrong number or not

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

    Sir.. In 2nd step.. We hv to initialize q value again. q=number, because.. In 1st step.. q becoming 0 ..

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

    It can be done in simpler way
    t=n;
    sum=0;
    while(n>0)
    {
    r=n%10;
    sum=sum+(r*r*r);
    n=n/10;
    }
    if (t==n)
    {
    printf("Armstrong Number
    ");
    }

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

    what if we take number in string and then use "strlen" to find number of input ?

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

    Good explanation ❤

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

    Thank u sir for great explanation 🎉🎉❤

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

    sir shouldn't we initialize mul to 1 initially

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

    If it is four digits number means how to write the program .... I struggle to write that program.... Please tell me sir ....

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

    Lovee u man....Really u are a legend...If i meet u in person then ill hug u and give u some gifts.. :-)

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

    Thank you so much sir 💥💥

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

    I would code it like this
    int main()
    {
    int n, number, o, number1=0, temp, i;
    printf("Enter your number:");
    scanf("%d", &number);
    number1=number;
    temp=number;
    int result=0;
    i=0;
    while(number!=0)
    {
    number=number/10;
    i++;
    }
    while(number1!=0)
    {
    n=number1%10;
    result=result+pow(n,i);
    number1=number1/10;
    }
    if(temp==result)
    {
    printf("Your number is armstrong");
    }
    else
    {
    printf("Your number is not armstrong bro");
    }

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

    sir can you tell me plzz that how we are getting numbers in mul variable

  • @tech-helpbuddy2815
    @tech-helpbuddy2815 2 ปีที่แล้ว

    I have a doubt. Is 2-9 an Armstrong number? because this code says they are?

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

    thank you so much

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

    7:33 i caught you stanger >:)

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

    For single digit values it is wrong program. Because it is showing 2,3,4... As Armstrong numbers but they are not.
    The definition is sum of the cubes of the each digit of the number is equal to the number itself

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

    thankyou sir 🙏

  • @RajeshSanagala-ro2yk
    @RajeshSanagala-ro2yk ปีที่แล้ว

    Can anyone plz explain me that why he initialized mul=1 in the last of second step

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

      @Rajesh Sanagala
      We have initialize mul=1 as 1 is the only number after multiply with we get the same number and moreover we have to use the mul variable each time the loop run and If we don't initialize it with 1 then we will be multiplying the new digit with the previous result
      Like
      Nu=153
      mul=mul*rem // (1*3=3**3=9)
      For next digit we need to have the mul variable as 1 only
      mul=mul*rem //(1*5=5)
      Otherwise we will get 9*5 but we have to add the digit power 3..

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

    N my clg they don't teach concepts never they just copy aloud programs ND hence we have to cram them up

  • @SurajChaudhary-mp1uw
    @SurajChaudhary-mp1uw 4 ปีที่แล้ว

    Tnks sir g

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

    what is the need of count the digits of number? we can do it without counting the digits.
    # include
    int main()
    {
    int num,n,r,sum=0;
    printf("Enter Your Number: ");
    scanf("%d",&num);
    n=num;
    while(n>0)
    {
    r=n%10;
    sum=sum+r*r*r;
    n=n/10;
    }
    if(sum==num)
    printf("Yes. NO is Armstrong
    ");
    else
    printf("NO. No is not Armstrong
    ");
    }

  • @snehashishkar2239
    @snehashishkar2239 10 หลายเดือนก่อน +1

    Why i am getting 1278 as answer for any input 🤬🤬L

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

    I tried before seeing the answer
    int n;
    int main() {
    printf("Armstrong number? ");
    scanf("%d", &n);
    int counter = 0;
    int holder = n;
    while(n != 0) {
    n = n / 10;
    counter++;
    }
    n = holder;
    int i = counter;
    int sum = 0;
    int rem;
    int mul = 1;
    while(holder != 0) {
    rem = holder % 10; //most left number
    holder = holder / 10;
    while(counter > 0) {
    mul = mul*rem;
    counter--;
    }
    sum = sum + mul;
    counter = i;
    mul = 1;
    }
    if(sum == n) {
    printf("Yes!", sum);
    }
    else
    printf("No!", sum);
    }

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

    #include
    #include
    int main()
    {
    int num,temp,digits,count=0;
    printf("enter a number: ");
    scanf("%d",&num);
    temp=digits=num;
    //counting the number of digits
    while(digits!=0)
    {
    digits=digits/10;
    count++;
    }
    int r;
    int s=0;
    //multiplying each digits "count" times and adding them
    while(num!=0)
    {
    r=num%10;
    r=pow(r,count);//multiplying using pow function
    s=s+r;//adding here
    num=num/10;
    }
    if(temp==s)
    {
    printf("armstrong number");
    }
    else
    {
    printf("not an armstrong number");
    }
    return 0;
    }

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

    Why cnt=3?

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

      Because if its 3. it reduces to 0 and it can not be looped again for the remaining values we need to multiply

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

      so after it becomes 0 you basically need to set it to 3 again, so it continues that process of Looping. I hope I could help

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

    Is 2,3,4 armstrong number???

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

      Numbers from 0-9 are Armstrong numbers

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

    ❤️❤️

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

    3%10=0.3

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

      remainder is 0

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

      @@saikiran5345 a small number % a bigger one is the smal one ==> so 3%10 is 3 bro (modulo property)

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

      As clearly the left-hand side number is left than right hand side number....the result would be left hand side number ...without doubt

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

      no its remainder so it would be 3

  • @md.sharifulislamasif6341
    @md.sharifulislamasif6341 4 ปีที่แล้ว

    I think actual code is this. Here cnt = count will be inside of second while loop. #include
    int main()
    {
    //Find order of the number
    int number, count=0, q, cnt, rem, mul=1, result=0;
    printf("Please enter a number: ");
    scanf("%d", &number);
    printf("Checking Number: %d
    ", number);
    q = number;
    while(q!=0)
    {
    q = q/10;
    count++;
    }
    printf("Order of that number: %d
    ", count);
    q = number;
    while(q!=0)
    {
    cnt = count;
    rem = q%10;
    while(cnt !=0)
    {
    mul = mul*rem;
    cnt--;
    }
    result = result + mul;
    q = q/10;
    mul = 1;
    }
    printf("After multiplication with Order of that number: %d
    ", result);
    //Is Armstrong Number or Not
    if(result == number)
    printf("%d is an Armstrong Number
    ", number);
    else
    printf("%d is not an Armstrong Number
    ", number);
    }

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

    #include
    int main()
    { int num=0;
    int x;
    printf("Enter the number: ");
    scanf("%d",&x);
    int num0=x;
    int a=x;
    int i=0;
    while(a>0)
    {
    a=a/10;
    i++;
    }
    while(x!=0)
    {
    num=num+pow(x%10,i);
    x=x/10;
    }
    if(num0==num)
    printf("The entered number is a armstrong");
    else
    printf("The entered number is NOT a armstrong");
    return 0;
    }

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

    😀 before i saw your result i tried to find the solution by myself and here are it's . long but worked 😂😂
    #include
    #include
    int power (int *y,int *n);
    int main ()
    {
    unsigned int b,y,n,input,result =0;
    printf("Enter a number:");
    scanf("%i",&b);
    input = b;
    n = log10(b)+1;
    for(int i = 1; i

  • @omarghazi-n3s
    @omarghazi-n3s 8 หลายเดือนก่อน

    this my code >> # include
    int len(int n)
    {
    int size;
    size = 0;
    while (n > 0)
    {
    size++;
    n /= 10;
    }
    return (size);
    }
    void is_armstrong(int n)
    {
    int size ;
    int nb = n;
    int reminder = 0;
    int check;
    int total = 0;
    while (nb > 0)
    {
    reminder = nb % 10;
    check = 1;
    size = len(n);
    while (size > 0)
    {
    check *= reminder;
    size--;
    }
    total += check;
    nb /= 10;
    }
    if (total == n)
    printf("is armstrong");
    else
    printf("its not armstrong");
    }
    int main()
    {
    is_armstrong(3);
    }

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

    i cheated and i used the math library so i can use pow instead of while

  • @porankirajkumar4709
    @porankirajkumar4709 4 ปีที่แล้ว +17

    Thanks a lot ❤️❤️❤️because of you I am in love with c❤️

    • @PoojaMishra-xc6lp
      @PoojaMishra-xc6lp 3 ปีที่แล้ว

      Yar how can you love it...I'm unable to understand c language..can you help me

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

      @@PoojaMishra-xc6lp start from the first lecture of c programming of neso,eventually u will understand everything

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

      So true in mine case

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

      @@ramarajujaya2480 yes it is true in my case also ❤️❤️
      Neso is the best ❤️❤️

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

    sir how to store this complex logic inside my head for ever? i understood it but im sure i will forget it after a day or two

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

    you can determinate the length of number with length (type int ) length=log10(number)+1

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

    int main()
    {
    int number,rev,arm,result=0;
    int q;
    int digit=0;
    printf("Enter a number
    ");
    scanf("%d",&number);
    rev=number;
    arm=number;
    while(rev!=0)
    {
    digit++;
    rev=rev/10;
    }
    while(arm!=0)
    {
    int mult=1;
    q=arm%10;
    for(int i=1;i

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

    How simple u made that program !!!
    Aapki wajah se samjha muze ye...🤵‍♀️

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

    thank you so much for this video
    helped me clearing the concept of Armstrong no...
    thanks

  • @hrishikeshkashyap3715
    @hrishikeshkashyap3715 9 หลายเดือนก่อน +1

    Inside the nested WHILE loop, can we use a FOR loop instead of the WHILE loop????
    Like for example:
    for(cnt=count;cnt>0;cnt--)
    {
    mul=mul*rem;
    }

  • @janhvinarayan1633
    @janhvinarayan1633 9 หลายเดือนก่อน +2

    sir should've shown the whole code too before/after the snippets 🥲🥲

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

    Flew over my head

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

    It's so funny that this is the second exercise in Exercism for C right after Hello World lol. As a newbie, I thought there would be more a gradual escalation

  • @gopalkrishna9130
    @gopalkrishna9130 5 ปีที่แล้ว +8

    can't we directly use pow function instead of multiplying?

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

      You can use that but that will not actually give u the feeling of the logic of making a number raise to some power

  • @YoYo-nt7yf
    @YoYo-nt7yf 4 ปีที่แล้ว +3

    I'm soooooooo happy rn I've understood very well
    Tsym

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

    Thank you so much sir...now next one should be about Strong number...

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

    Easier Way
    int main()
    {
    int InitialNum, FinalNum = 0, tempcontianer = 0, count = 0;
    cin >> InitialNum;
    count = log10(InitialNum) + 1;
    tempcontianer = InitialNum;
    while (tempcontianer != 0)
    {
    FinalNum += pow(tempcontianer%10, count);
    tempcontianer /= 10;
    }
    cout

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

    what happen if user give four digit no.?
    while loop will run four time mean in place of cube we get four time multiple?

  • @AmitKumar-ec7le
    @AmitKumar-ec7le 7 หลายเดือนก่อน

    Baad mein kyu cnt or mul ko intialize kiye h koi baatayega hmko

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

    your explanation is crystal clear. But, what is the use of again assigning the cnt=count &mul=1 in the while loop??

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

      see the value changed inside while is permanent...not temprary

    • @k.y201
      @k.y201 2 ปีที่แล้ว

      @@its_SR07 if its permanent then again mul value is changed into 343 right then is that 3 want to multiple with 343?

    • @VISHALHS-qw1hc
      @VISHALHS-qw1hc ปีที่แล้ว +2

      count=n; //count n again, for next digit
      q/=10; //to omit the used digit :) omitting starts from ones place :)
      //mul=1;
      like it if u like :) so that others can see :)

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

    //code for Armstrong Number right or wrong?sir
    #include
    #include
    int main()
    {
    int n , q , rem;
    int result = 0;
    printf("enter value of n:");
    scanf("%d" , &n);
    q = n;
    while(q != 0){
    rem = q % 10;
    result += pow(rem , 3);
    q = q / 10;
    }
    printf("%d
    " , result);
    if(result==n)
    printf("its a armstrong number!");
    else
    printf("its not a armstrong number!");
    return 0;
    }

    • @sanandn.r7889
      @sanandn.r7889 ปีที่แล้ว

      header lines are obvious in every programs. i guess thats why he didnt mention

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

    Sir Why this code shows every number , an Armstrong number...?? there is some mistake in this code. (Sir can you fix it).
    #include
    #include
    int main()
    {
    int number,count=0,result=0,mul=1,cnt,rem;
    printf("Enter a number
    ");
    scanf("% d ",&number);
    int q = number;
    while(q !=0)
    {
    q = q/10;
    count++;
    }
    cnt = count;
    q = number;
    while(q!=0)
    {
    rem=q%10;
    while(cnt!=0)
    {
    mul= mul*rem;
    cnt--;
    }
    result = result + mul;
    cnt=count;
    q = q/10;
    mul = 1;
    }
    if(result == number)
    {
    printf("%d is an Armstrong no", number);
    }
    else
    {
    printf("%d is not an Armstrong no", number);
    }
    return 0;
    }

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

      @Darshan patil did you find out ?

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

      In scanf remove that gap between % and d then it's working. I checked.

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

      @@paraprannoy3732 yeah thank you

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

    You are awesome man! 😵

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

    Sir upload videos on arrays , strings, pointers

  • @Raj-n4p4h
    @Raj-n4p4h 8 หลายเดือนก่อน

    👌👌👌👌👌👌👌👌👌👌

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

    Can also ** operator for exponentiation of each digit to its order and then adding simultaneously

  • @tayyab.sheikh
    @tayyab.sheikh 9 หลายเดือนก่อน

    I didn't understood why did you wrote this :
    cnt = count
    and q = number

    • @vinitph
      @vinitph 8 หลายเดือนก่อน +1

      Which cnt for first one we have given the value of count to cnt variable so that changing anything in cnt doesn't affect count
      For second one Count is = 3 we initialised cnt to 3 by equating it to count as while loop mein cnt ki value humne 0 kardi thi last process mein

    • @vinitph
      @vinitph 8 หลายเดือนก่อน +1

      Same with q while counting the no. Of digits for our given no. Humne q ki value 0 kardi thi we initialised it back to our original no.

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

    It's better to use pow( ) under math.h💁

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

    Guys i tried it myself also this lecture but that was not running . I had done a blunder by putting ; after while😂 but i am happy . now my program is running successfully.

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

    What if you have a number with more digists then 3? can u use pow somehow in the code?

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

      yep

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

      !! Well if you include math.h (By which you can include pow) in the header files it can be easier !! :)
      #include
      #include
      int main(){
      int num,temp,rem,result=0,count=0;
      printf("enter the number that you want to check
      ");
      scanf("%d",&num);
      temp=num;
      while(temp!=0){
      temp=temp/10;
      count++;
      }
      temp=num;
      while(num>0){
      rem=num%10;
      result=result+pow(rem,count);
      num=num/10;
      }
      if(temp==result)
      {
      printf("It is an armstrong number
      ");
      }
      else{
      printf("It is not an armstrong number
      ");
      }
      return 0;
      }#include
      #include
      int main(){
      int num,temp,rem,result=0,count=0;
      printf("enter the number that you want to check
      ");
      scanf("%d",&num);
      temp=num;
      while(temp!=0){
      temp=temp/10;
      count++;
      }
      temp=num;
      while(num>0){
      rem=num%10;
      result=result+pow(rem,count);
      num=num/10;
      }
      if(temp==result)
      {
      printf("It is an armstrong number
      ");
      }
      else{
      printf("It is not an armstrong number
      ");
      }
      return 0;
      }

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

    Mine output is not coming
    It is showing else statement

  • @sarwariKhatoon-ug7or
    @sarwariKhatoon-ug7or ปีที่แล้ว

    Sir plz make video on automorphic number

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

    And I can easily understand your explanation

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

    I don’t understand the use of cnt=count here

  • @VISHALHS-qw1hc
    @VISHALHS-qw1hc ปีที่แล้ว

    struggled to understand ur explaination using example, but successfully understood. thanks alot for ur contribution in sharing huge amouts of knowledge.

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

    thanks sirbut can u make videsos onn microprocessors arm7

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

    Canu pls share Ur code

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

    Awesome explanation sir

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

    After line 30 , cnt should again initialize to count

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

    Sir also make videos on java for beginners

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

    Nice video sir

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

    Thanks alot

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

    Thank u

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

    thank you sir, you explained very well

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

    Can u tell me which part of code is wrong? I am getting the wrong output.
    #include
    #include
    #include
    int main()
    {int n,x=0,count=0,temp,temp1,rem,sum=0;
    printf("enter no.");
    scanf("%d",&n);
    temp=n;
    while(temp!=0)
    {
    temp=temp/10;
    count++;
    }
    temp1=n;
    x=count;
    while(x!=0)
    {
    rem=temp1%10;
    sum=sum+pow(rem,count);
    x--;
    }
    if(sum==n)
    printf("yes");
    else
    printf("NO");
    return 0;
    }

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

      instead of x-- use temp1=temp1/10; and in the condition in while use : temp1!=0.

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

      @@aakashmudigonda3375 thank you

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

    Very nice video sir but sir jb 37/10=30
    Count =7 hoga
    30/10=3
    Count=0
    3/10=0
    Count=3

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

      We are storing the value of 37/10 in 'q' not in count and in next step we are simply incrementing the count variable to find the order of number.

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

      37/10 = 3

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

    Why we are using cnt =count ?
    We can declare int count =0

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

      Because we've use ‘count' to count the digit of the number at first step and in second step we're using cnt instead of count as count variable was used earlier

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

    3/10 =0?

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

      Yes if the variable in which you store it is integer

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

    06:54
    Can someone tell me how would that while(cnt!=0) is gonna work bec the mul variable inside it is initialised below that loop, so isn't it that basically the mul inside the while(cnt!=0) is still initialised?

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

      as we got the value of cnt from previous function and before entering the while loop the condition will be checked and if the condition will be true so code will be executed. and mul is initialised in main function recheck the full snippet and ya we again initialised mul as 1 so that we can again multiply the left digits with their respective order . thanku and watch this video again.

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

      @@harmankaur3938 Thanks for help and info mate!
      Appreciated 👏

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

    Can anyone tell me , why we have to initialize q separately ?

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

      Suppose n is the number you want to count the digits then let q= n then follow the code given, we don't want the number n which is given as input to change so we are using another variable q. Is my explanation clear ?

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

    Sir i am new at programming pls suggest me do we have to memorize the codes or from time we'll have it practiced

    • @sanandn.r7889
      @sanandn.r7889 ปีที่แล้ว

      pratice makes a man prefect you havent head that. dont use your memory here. experience is the mother of all wisdom

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

    this is my code
    #include
    #include
    int main()
    {
    int num,result=0,rem,p,order=0;
    printf("Enter Num:
    ");
    scanf("%d",&num);
    p=num;
    int q=num;
    while(q!=0)
    {
    order++;
    q=q/10;
    }
    while(p>0)
    {
    rem=p%10;
    result =result+pow(rem,order);
    p=p/10;
    }
    if(num==result)
    {
    printf("ArmStrong");
    }else{
    printf("LegStrong");
    }

    return 0;
    }

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

    (is my code correct for armstrong number?), #include
    #define p(a) printf("%d", a)
    #define scan(x) scanf("%d", &x)
    int main()
    {
    int a, b,c, save;
    scan(a);
    save = a;
    while(a>0){
    b = a%10;
    c = c + (b*b*b);
    a = a/10;
    }
    //p(c);
    if(c == save){
    p(1);
    }
    else{
    p(2);
    }
    return 0;
    }
    expand_more