Automorphic number in C

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 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 →

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started