Posts

Showing posts from August 22, 2012

PROGRAM TO FIND OCTAL OF A NUMBER

LIST OF PROGRAMS
#include<stdio.h>
#include<conio.h>
void main()
{
long int n,oct=0,r=1,pow=1;
 clrscr();

printf("Enter a number ");
scanf("%ld",&n);

if(n<0)
printf("WRONG INPUT");

else
{
 if(n<=7&&n>=0)
 oct =n;

 else
 {
 while(n>0)
 {
r=n%8;
oct=oct+(r*pow);
n=n/8;
pow=pow*10;
 }
 }

 printf("OCTAL = %ld",oct);
 getch();
}
}

LIST OF PROGRAMS

program to find sum of first and last digit of a number

LIST OF PROGRAMS

#include<stdio.h>
#include<conio.h>

void main()
{
long int n,sum=0,last;
 clrscr();

printf("Enter a number ");
scanf("%ld",&n);

if(n<=9&&n>=0)
printf("sum = %ld",n);

else if(n<0)
printf("WRONG INPUT");

else
{
last=n%10; /*for finding last digit of the number */
while(n>9)
{
n=n/10;
}

sum=n+last;
printf("SUM =%ld",sum);
getch();

}
}

LIST OF PROGRAMS