Source Code :
#include<stdio.h>
#include<conio.h>
void main(void)
{
int no,a,b,c,d,e,f,sum14,sum12,sum13,pro12,pro14,pro13,sub12,sub13,sub14;
float div12,div13,div14;
clrscr();
printf("Enter a 4 digit number:");
scanf("%d",&no);
printf("\n\t Extracing singal digits from a code");
printf("\n\t-------------------------------------");
a=(no/1000);
b=(no%1000);
c=(b/100);
d=(b%100);
e=(d/10);
f=(d%10);
sum14=(a+f);
sum12=(a+c);
sum13=(a+e);
pro14=(a*f);
pro12=(a*c);
pro13=(a*e);
sub14=(a-f);
sub12=(a-c);
sub13=(a-e);
div13=(a/e);
div12=(a/c);
div14=(a/f);
printf("\nThe first number is : %d",a);
printf("\nThe second number is : %d",c);
printf("\nThe third number is : %d",e);
printf("\nThe Fourth number is : %d",f);
printf("\n\nThe sum of the first and the last numbers are :
%d",sum14);
printf("\nThe sum of the first and the second numbers are :
%d",sum12);
printf("\nThe sum of the first and the third numbers are :
%d",sum13);
printf("\n\nThe product of the first and the last numbers are
: %d",pro14);
printf("\nThe product of the first and the second numbers are
: %d",pro12);
printf("\nThe product of the first and the third numbers are
: %d",pro13);
printf("\n\nThe subtract of the first and the last numbers
are : %d",sub14);
printf("\nThe subtract of the first and the second numbers
are : %d",sub12);
printf("\nThe subtract of the first and the third numbers are
: %d",sub13);
printf("\n\nThe devide of the first and the last numbers are
: %.2f",div14);
printf("\nThe devide of the first and the second numbers are
: %.2f",div12);
printf("\nThe devide of the first and the third numbers are :
%.2f",div13);
getch();
}
No comments:
Post a Comment