Generate no.between 32 to 99

Consider the following number
45*45=2025 and
20+25=45.
Write a program to generate no.between 32 to 99 that satisfy the above problem.

Questions by mounik

Showing Answers 1 - 15 of 15 Answers

mahamadalig

  • Apr 17th, 2012
 

Code
  1. #include<stdio.h>

  2. #include<conio.h>

  3. main()

  4. {

  5.         int i,a,r,s,w;

  6.         printf("                ------ANSWER IS:---------

  7. ");

  8.         for(i=32;i<=99;i++)

  9.         {

  10.                 s=0;

  11.                 w=i;

  12.                 a=i*i;

  13.                 while(a>0)

  14.                 {

  15.                         r=a%100;

  16.                         s=s+r;

  17.                         a=a/100;

  18.                 }

  19.                 if(w==s)

  20.                 {

  21.                         printf("                           %d

  22. ",w);

  23.                 }      

  24.         }

  25.         return 0;

  26. }

  Was this answer useful?  Yes

Sambuddha Chaudhuri

  • Jul 16th, 2015
 

Code
  1. public class sumbtw32and45{

  2.     public static void main(String args[]){

  3.         //Scanner sc = new Scanner(System.in);

  4.         //System.out.println("Enter the number between 32 and 99");

  5.         //int i = sc.nextInt();

  6.         //if(i >=32 && i <= 99)

  7.         int count = 0;

  8.             for(int i =32;i<=99;)

  9.             {

  10.             int j =i * i;

  11.             int temp = j %100;

  12.             int n = j /100;

  13.             int l = temp + n;

  14.             if(i == l){

  15.                System.out.println(i);

  16.                count = count +i;

  17.                i++;

  18.             }

  19.             else

  20.                i++;

  21.            }

  22.            System.out.println("the Sum of these Type of numbers is"+count);

  23.            }

  24. }

  Was this answer useful?  Yes

Sunil Shenoy

  • May 16th, 2016
 

Solved using mod operator.

Code
  1. #include<iostream>

  2. using namespace std;

  3. main()

  4. {

  5.     int x,a,b,y,val;

  6.     cout<<"valid numbers between 32-99 based on given algorithm is: "<<endl;

  7.     for(x=32;x<100;x++)

  8.     {

  9.     y=x;

  10.     val=x*x;

  11.     a=val/100;

  12.     b=val%100;

  13.     if((a+b)==y)

  14.     {

  15.         cout<<"selected Number is:"<<y<<endl;

  16.         cout<<"Square of given value "<<y<<"="<<val<<endl;

  17.         cout<<"Quetiont: "<<a<<"

  18. "<<"Reminder: "<<b<<endl;

  19.         cout<<a<<"+"<<b<<"="<<y<<endl;

  20.         cout<<endl;

  21.         cout<<endl;

  22.     }

  23.     }

  24. }

  25.  

  Was this answer useful?  Yes

anonymous

  • Apr 5th, 2017
 

Basically the same, but in node :)

Code
  1. var desired = [];

  2. for(var i = 32; i <= 99; i++) {

  3.  

  4.   var value = i * i;

  5.   var split1 = parseInt(value / 100);

  6.   var split0 = value % 100;

  7.   if(split1 + split0 == i) {

  8.     desired.push(i);

  9.   }

  10. }

  11.  

  12. console.log("Desired values: " + desired);

  Was this answer useful?  Yes

gyanendra verma

  • Aug 20th, 2017
 

Code
  1. #include<stdio.h>

  2. void main()

  3. {

  4. int n1,n2,i,temp,b,j,c,check,count=0,a[4];

  5. clrscr();

  6. printf("enter starting number: ");

  7. scanf("%d",&n1); //n1=32

  8. printf("enter ending number: ");

  9. scanf("%d",&n2);  //n2=99

  10. for(i=n1;i<=n2;i++)

  11. {

  12. temp=i*i;

  13. j=0;

  14. while(temp>0)

  15. {

  16.   b=temp%10;

  17.   a[j]=b;

  18.   temp=temp/10;

  19.   j++;

  20. }

  21. check=(a[3]*10)+a[2]+(a[1]*10)+a[0];

  22. if(check==i)

  23. {

  24. printf("%d ",i);

  25. count++;

  26. }

  27. }

  28. if(count==0)

  29. printf("sorry there is no any number");

  30. getch();

  31. }

  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