Write a program to reverse a given number in C?

#include #include main() { int n, reverse=0, rem; //declaration of variables. clrscr(); // It clears the screen. printf(“Enter a number: “); scanf(“%d”, &n); while(n!=0) { rem=n%10; reverse=reverse*10+rem; n/=10; } printf(“Reversed Number: %d”,reverse); getch(); // It reads a character from the keyword. } Certainly! Here’s a simple program in C to reverse a given number: cCopy … Read more

Write a program to check Armstrong number in C?

#include #include main() { int n,r,sum=0,temp; //declaration of variables. clrscr(); //It clears the screen. printf(“enter the number=”); scanf(“%d”,&n); temp=n; while(n>0) { r=n%10; sum=sum+(r*r*r); n=n/10; } if(temp==sum) printf(“armstrong number “); else printf(“not armstrong number”); getch(); //It reads a character from the keyword. } Sure, here’s a C program to check if a number is an Armstrong … Read more

Write a program to print factorial of given number using recursion?

#include #include long factorial(int n) // function to calculate the factorial of a given number. { if (n == 0) return 1; else return(n * factorial(n-1)); //calling the function recursively. } void main() { int number; //declaration of variables. long fact; clrscr(); printf(“Enter a number: “); scanf(“%d”, &number); fact = factorial(number); //calling a function. printf(“Factorial … Read more

Write a program to print factorial of given number without using recursion?

#include #include void main(){ int i,fact=1,number; clrscr(); printf(“Enter a number: “); scanf(“%d”,&number); for(i=1;i<=number;i++){ fact=fact*i; } printf(“Factorial of %d is: %d”,number,fact); getch(); } Certainly! Here’s a C program to calculate the factorial of a given number without using recursion: cCopy code #include <stdio.h> unsigned long long factorial(int num) { unsigned long long fact = 1; // … Read more

Write a program to check palindrome number in C Programming?

#include #include main() { int n,r,sum=0,temp; clrscr(); printf(“enter the number=”); scanf(“%d”,&n); temp=n; while(n>0) { r=n%10; sum=(sum*10)+r; n=n/10; } if(temp==sum) printf(“palindrome number “); else printf(“not palindrome”); getch(); } Certainly! Below is a C program to check if a given number is a palindrome or not: cCopy code #include <stdio.h> int main() { int n, reversedN = … Read more