Saturday, June 26, 2010

program in C to find the 2 digit number which is 3 times its sum of its digits

1) main()
{
int num,sum,i;
for(num=10;num<100;num++)
{
if(num==3*(num%10+num/10))
{
printf("%d",num);
}
}
}



2)
#include
void main()
{
int i a c;
for(i 10;i< 99;i++)
{a i;
c i 10;
a a/10;
if(i (3*(c+a)))
{
printf(" d" i);
getch();
}
}
getch();
}


3)

#include
void main()
{
int i t r s x;
clrscr();

for(i 10;i< 99;i++)
{
s 0;
t i;
while(t! 0)
{
r t 10;
t t/10;
s s+r;
}
x (3*s);
if(x i)
printf(" dn" i);
}
getch();
}

No comments:

Post a Comment