Write a C program
to check whether a given number is An Automorphic number or not. or Write
a program to check whether a given number is An Automorphic number
or not in C.
Program in C
Code:
/*Write a C program to check
whether a given number is An Automorphic number or not. or Write a
program to check whether a given number is An Automorphic number or
not Using C*/
#include<stdio.h>
int main()
{
int num;
printf("Enter a number:");
scanf("%d",&num);
int sqr=num*num;
int flag=0;
while(num>0)
{
if(num%10 != sqr%10)
{
flag=-1;
break;
}
num=num/10;
sqr=sqr/10;
}
if(flag==0)
printf("It is an Automorphic Number");
else
printf("It is not an Automorphic Number");
}
Input/Output:
Enter a number:6
It is an Automorphic Number
Write a C++ program
to check whether a given number is An Automorphic number or not. or Write
a program to check whether a given number is An Automorphic number or not in C++.
Program in C++
Code:
/*Write a C++
program to check whether a given number is An Automorphic number or
not. or Write a program to check whether a given number is An
Automorphic number or not using C++*/
#include<iostream>
using namespace std;
int main()
{
int num;
cout<<"Enter a number:";
cin>>num;
int sqr=num*num;
int flag=0;
while(num>0)
{
if(num%10 != sqr%10)
{flag=-1;
break;
}
num=num/10;
sqr=sqr/10;
}
if(flag==0)
cout<<"It is an Automorphic Number";
else
cout<<"It is not an Automorphic Number";
}
Input/Output:
Enter a number:845
It is not an Automorphic Number
Write a JAVA
program to check whether a given number is An Automorphic number or
not. or Write a program to check whether a given number is An
Automorphic number or not in Java.
Program in Java
Code:
/*Write a JAVA
program to check whether a given number is An Automorphic number or
not. or Write a program to check whether a given number is
An Automorphic number or not using Java*/
import java.util.Scanner;
public class AutomorphicNumberOrNot {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
int num;
System.out.println("Enter a number:");
num=cs.nextInt();
int sqr=num*num;
int flag=0;
while(num>0)
{
if(num%10 != sqr%10)
{flag=-1;
break;
}
num=num/10;
sqr=sqr/10;
}
if(flag==0)
System.out.println("It is an Automorphic Number");
else
System.out.println("It is not an Automorphic Number");
cs.close();
}
}
Input/Output:
Enter a number:
25
It is an Automorphic Number
Write a PYTHON to check
whether a given number is An Automorphic number or not. or Write a
program to check whether a given number is An Automorphic number or not in
Python
Program in Python
Code:
'''Write
a Python program to check whether a given number is An Automorphic
number or not. or Write a program to check whether
a given number is An Automorphic number or not using Python '''
num=int(input("Enter a number:"))
sqr=num*num
flag=0
while num!=0:
if(num%10 != sqr%10):
flag=-1
break
num=int(num/10)
sqr=int(sqr/10)
if(flag==0):
print("It is an Automorphic Number")
else:
print("It is not an Automorphic Number")
Input/Output:
Enter a number:76
It is an Automorphic Number
Most Recommend Questions:-
More Questions:-
Most Recommend Questions:-
More Questions:-
0 Comments
Please do not Enter any spam link in the comment box