This is a program show the applications the mod (%) operation.
/*This is a program to input three digit number from user and display square of first and last number */
#include<stdio.h>
int main()
{
int num,rem,sqr1,sqr2;
start:
printf("Enter a three digit number ");
scanf("%d",&num);
if(num>999){
printf("\nSorry you have Entered long number\n");
goto start;
}
if(num<100){
printf("\nSorry you have entered short number\n");
goto start;
}
rem=num%10;
sqr2=rem*rem;
num=num/10;
num=num/10;
sqr1=num*num;
printf("\nThe square of the first digit is %d and the square of the last digit is %d \n",sqr1,sqr2);
return 0;
}
The output of this program ....
0 comments:
Post a Comment