Who can help me in this program?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • isabelle
    New Member
    • Dec 2006
    • 14

    Who can help me in this program?

    Let n=akak-1ak-2…a1a0 be an integer and t=a0-a2-…+ (-1) k. It is known that n is divisible by 11 if and only if t is divisible by 11.for example, suppose that n=8784204.then t=4-0+2-4+8-7+8=11.because 11 is divisible by 11, it follows that 8784204 is divisible by 11.If n= 54063297, then t=7-9+2-3+6-0+4-5=2.because 2 is not divisible by 11, 54063297 is not divisible by 11.Write a program that prompts the user to enter a positive integer and then uses this criterion to determine whether the number is divisible by 11.

    If anyone can help me to write this program I will be grateful because I have quiz next week and I want the solution for this program.
  • suganya
    New Member
    • Dec 2006
    • 39

    #2
    void main()
    {
    // To find whether a given number is divisible by 11
    int no,res = 0;
    printf("\n Enter any positive no. ");
    scanf("%d",&no) ;
    while(no > 0)
    {
    res = res + ((no % 10) - (no / 10)%10);
    no = no / 100;
    }
    if(res/11)
    printf("\n The given no is divisible by 11");
    else
    printf("\n The given no is not divisible by 11");
    getch();
    }

    Comment

    • isabelle
      New Member
      • Dec 2006
      • 14

      #3
      Think you for your help,This great!

      And any body has another solution I will be grateful.

      Comment

      • DeMan
        Top Contributor
        • Nov 2006
        • 1799

        #4
        If you search this forum, you will find that this question has already been addressed in the last week....

        Comment

        Working...