#include<stdio.h>
#include<conio.h>
int reverse(int);
void main()
{
int n,r;
clrscr();
printf("Enter a number");
scanf("%d", &n);
r = reverse(n);
printf("%d\n",r);
getch();
}
int reverse(int n)
{
static long r = 0;
if(n == 0)
{
return 0;
}
r = r * 10;
r = r + n % 10;
reverse(n/10);
return r;
}
To Compile Press Alt+f9
To Run Press Ctrl+f9
Output:
#include<stdio.h>
#include<conio.h>
void main()
{
int dividend, divisor, quotient, remainder;
clrscr();
printf("Enter the Dividend: ");
scanf("%d", ÷nd);
printf("Enter the divisor: ");
scanf("%d", &divisor);
quotient = dividend/divisor;
remainder = dividend%divisor;
printf("Quotient: %d\n",quotient);
printf("Remainder: %d",remainder);
getch();
}
To Compile Press Alt+f9
To Run Press Ctrl+f9
Output:
#include<stdio.h>
#include<conio.h>
void main()
{
int n, n1, rem, num=0;
clrscr();
printf("Enter a positive integer: ");
scanf("%d", &n);
n1=n;
while(n1 != 0)
{
rem = n1%10;
num+=rem*rem*rem;
n1/=10;
}
if(num == n)
printf("%d is an Armstrong number.",n);
else
printf("%d is not an Armstrong number.",n);
getch();
}
To Compile Press Alt+f9
To Run Press Ctrl+f9
Output:
#include<stdio.h>
#include<conio.h>
void main()
{
int n1, n2, quotient, remainder;
clrscr();
printf("Enter two numbers \n");
scanf("%d%d",&n1,&n2);
quotient = n1/n2;
remainder = n1 - quotient * n2;
printf("%d",remainder);
getch();
}
To Compile Press Alt+f9
To Run Press Ctrl+f9
Output:
#include<stdio.h>
#include<conio.h>
void main()
{
int n, reverse=0;
clrscr();
printf("Enter any 4 numbers to reverse\n");
scanf("%d", &n);
while(n != 0)
{
reverse = reverse*10;
reverse = reverse+n%10;
n = n/10;
}
printf("Reverse of entered number is = %d\n",reverse);
getch();
}
To Compile Press Alt+f9
To Run Press Ctrl+f9
Output:
#include<stdio.h>
#include<string.h>
void main()
{
char str[100], temp;
int i,j = 0;
printf("\nEnter the string: ");
gets(str);
i = 0;
j = strlen(str) - 1;
while(i < j)
{
temp = str[i];
str[i] = str[j];
str[j] = temp;
i++;
j--;
}
clrscr();
printf("\nReverse string is :%s", str);
getch();
}
To Compile Press Alt+f9
To Run Press Ctrl+f9
Output: