#include "stdafx.h"

#include <conio.h>

#include <stdio.h>

int checkDivby9(int x)

{

int status = 0, ans = 0;

int divby8;

if(x < 9)

status = 0;

while(x >= 72)

{

x = x - 72;

ans = ans + 8;

}

divby8 = x >> 3;

//printf("%d\n",divby8);

//printf("%d\n",x);

if(divby8 == (x-(divby8 << 3)))

{

status = 1;

ans = ans + divby8;

}

//printf("%d\n",ans);

return status;

}

int _tmain(int argc, _TCHAR* argv[])

{

printf("Hello, World!\n");

int a;

a = 36;

if(checkDivby9(a))

printf("%d is divisible by 9\n", a);

a = 80;

if(checkDivby9(a))

printf("%d is divisible by 9\n", a);

a = 90;

if(checkDivby9(a))

printf("%d is divisible by 9\n", a);

a = 108;

if(checkDivby9(a))

printf("%d is divisible by 9\n", a);

a = 4500;

if(checkDivby9(a))

printf("%d is divisible by 9\n", a);

getch();

return 0;

}

Hello, World!

36 is divisible by 9

90 is divisible by 9

108 is divisible by 9

4500 is divisible by 9

#include <conio.h>

#include <stdio.h>

int checkDivby9(int x)

{

int status = 0, ans = 0;

int divby8;

if(x < 9)

status = 0;

while(x >= 72)

{

x = x - 72;

ans = ans + 8;

}

divby8 = x >> 3;

//printf("%d\n",divby8);

//printf("%d\n",x);

if(divby8 == (x-(divby8 << 3)))

{

status = 1;

ans = ans + divby8;

}

//printf("%d\n",ans);

return status;

}

int _tmain(int argc, _TCHAR* argv[])

{

printf("Hello, World!\n");

int a;

a = 36;

if(checkDivby9(a))

printf("%d is divisible by 9\n", a);

a = 80;

if(checkDivby9(a))

printf("%d is divisible by 9\n", a);

a = 90;

if(checkDivby9(a))

printf("%d is divisible by 9\n", a);

a = 108;

if(checkDivby9(a))

printf("%d is divisible by 9\n", a);

a = 4500;

if(checkDivby9(a))

printf("%d is divisible by 9\n", a);

getch();

return 0;

}

**OutPut:**Hello, World!

36 is divisible by 9

90 is divisible by 9

108 is divisible by 9

4500 is divisible by 9

## 0 comments :

## Post a Comment