C program to find 2 Digit Number

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

Questions by vidyanishant

Editorial / Best Answer

Piyush Dixit  

  • Member Since Sep-2009 | Sep 18th, 2009


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

Showing Answers 1 - 46 of 46 Answers

hydsarema

  • Nov 25th, 2008
 

#include<stdio.h>
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();
}

  Was this answer useful?  Yes

tarun88

  • Jan 8th, 2009
 

#include<stdio.h>
#include<conio.h>

void main()
{
int i,o,t;
clrscr();
for(i=10;i<=99;i++)
{
o=i%10;
t=i/10;
if(3*(o+t)==i)
{
printf("the req num is = %d",i);
break;
}
}
getch();
}

  Was this answer useful?  Yes

dharris999

  • Jan 30th, 2009
 

#include <stdio.h>
main()
{
    int x, y;
    for (x=0; x<=9; x++)
        for (y=0; y<=9; y++)
            if (((x*10)+y) == (3*(x+y)))
                printf("%d%dn", x, y);
}

  Was this answer useful?  Yes

#include<stdio.h>
void main()
{
int num,i,sum=0,rem=0;
for(i=10;i<100;i++)
{
num=i;
while(num!=0)
{
rem=num%10;
sum=sum+rem;
num=num/10;
}
if((3*sum)==i)
{
printf("number:=%d",i);
sum=0;rem=0;
break;
}

         sum=0;rem=0;
}
   }

  Was this answer useful?  Yes

#include<stdio.h>
#include<conio.h>

void main()
{
 int i,a,b,c,d;
 clrscr();
 printf("peciluar no r");
 for(i=10;i<100;i++)
{
 b=1;
 c=0;
 a=i;
 while(a>0)
{
  b=a%10;
  a=a/10;
  c=c+b;
}
  c=c*3;
if(c==i)
printf("%d",i);

}getch();
}//by manikandan

  Was this answer useful?  Yes

bolean a;
while(a)
{
  for(i=10;i<=99;i++)
    {
      int x,y,z;
      x=i/10;
      y=i%10;
      z=(x+y)*3;

        if(i==z)
           {
             a=false;
             printf("%d",i);
           }
     }
}

  Was this answer useful?  Yes

shwetha.s

  • Oct 11th, 2009
 

#include<stdio.h>
main()
{
int i,j;
for(i=10;i<100;i++)
{
        j=(i/10)+(i%10);
        if(i==(3*j))
        printf("%dn",i);
}
}

  Was this answer useful?  Yes

terna_engg

  • Oct 13th, 2009
 

#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
int i,j;
for(i=0;i<9;i++)
{
for(j=0;j<9;j=+)
{
if(((i*10)+j)=(3*(i+j)))
{
printf("%dn",10i+j);
}
else
{
printf("no number is found");
}
}
}
}

  Was this answer useful?  Yes

main()

{
int i; //datatype declaration

printf("The required numbers are:n"); //print the statement
for(i=10;i<100;i++) //calculate all 2 digit numbers
{
if(i==3*((i%10)+(i/10))) //satisfy the problem statement
printf("%dn",i); //print the numbers that satisfies the problem

}

}

  Was this answer useful?  Yes

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,l;
clrscr();
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
k = (i+j)*3;
l = 10*i + j;
if(k != 0 && l !=0)
{
if(k == l)
printf("%dn",l);
}
}
}
getch();
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions