ProAnswers.org

Write a C program to calculate the square of those numbers only whose least significant digit is 5

 #include<stdio.h>

#include<conio.h>

void main()

{

int s,d;

clrscr();

printf(“Enter a number:”);

scanf(“%d”, &s);

d=s%10;

if(d= =5)

{

s=s/10;

printf(“\n square=%d%d”, s*s++, d*d);

}

Else

Printf(“\n Invalid number”);

}

Output:

Enter a number: 25

Square =625 

Why we have to divide s by 10