Write a C Program to print the multiplication table
of a given number n up to a given value, where n is entered by the user.
SOURCE CODE:
/*Program to print the multiplication table of a given number.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,m,i;
clrscr();
printf("\nEnter number:");
scanf("%d",&m);
printf("\nEnter range:");
scanf("%d",&n);
for(i=1;i<=n;i++)
printf("\n%d * %d = %d",m,i,m*i);
}
OUTPUT:
Write a C Program to enter a
decimal number, and calculate and display the binary equivalent of that number.
SOURCE CODE:
/*Program to display binary equivalent of the given decimal number.*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
long int revbn=0,bn=0,dn,c=0;
clrscr();
printf("\nEnter decimal number:");
scanf("%ld",&dn);
while(dn>0)
{
revbn=(revbn*10)+(dn%2);
dn=dn/2;
c++;
}
while(c>0)
{
bn=(bn*10)+(revbn%2);
revbn=revbn/10;
c--;
}
printf("\nBinary number: %ld",bn);
}
OUTPUT:
Write a C Program to check
whether the given number is Armstrong number or not.
SOURCE CODE:
/*Program to check whether the given number is Armstrong number or not.*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,temp,arm=0,c=0;
clrscr();
printf("\nEnter number:");
scanf("%d",&n);
temp=n;
while(temp>0)
{
temp=temp/10;
c++;
}
temp=n;
while(temp>0)
{
arm=arm+pow((temp%10),c);
temp=temp/10;
}
if(n==arm)
printf("\nGiven number is Armstrong.");
else
printf("\nGiven number is not Armstrong.");
}
OUTPUT: