An Automorphic number is a number whose square ends with the same digits as the original. example: 5, 6 etc. #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int num, square, temp, last; int n =0; printf("Enter a number \n"); scanf("%d",&num); square = num*num; temp = num; while(temp>0){ n++; temp = temp/10; } int den =... Continue Reading →
C program to check for a perfect number
A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. example: 4: factors of 4 are 1, 2 nd 4 itself 1+2=3 , 4 is not a perfect number. #include <stdio.h> int main() { int number, rem, sum = 0, i; printf("Enter a Number\n");... Continue Reading →
C program to check whether a given number is a strong number or not
STRONG NUMBER: Strong number is a number whose sum of all digits’ factorial is equal to the number itself. example : 12 ; 1!+2! = 3 not a strong number #include <stdio.h> int factorial(int r) { int fact = 1; while(r>1) { fact = fact * r; r--; } return fact; } int check(int num)... Continue Reading →
C program to swap 2 numbers without using 3rd variable
It can be done using two methods: By using + and -By using * and / Method 1: By using + and - #include<stdio.h> int main() { int num1, num2; printf("Enter first number: ") ; scanf("%d",&num1); printf("\nEnter second number: ") ; scanf("%d",&num2); printf("\n Before swapping \n number_1= %d \n number_2 = %d",num1,num2); num1=num1+num2; num2=num1-num2; num1=num1-num2;... Continue Reading →
Python program to print all the prime numbers in a given range
The prime numbers are whole numbers greater than 1, that have only two factors – 1 and the number itself. Prime numbers are divisible only by the number 1 or itself. examples: 2*1=2 and 1*2=2 start = int (input("Enter the lower range ")) end = int (input("Enter the upper range ")) for i in range(start,... Continue Reading →