Computer Science, asked by brigit90, 3 months ago

write a program to calculate the square of those numbers only whose least significant digit is 5
what is the use of s*s++​

Attachments:

Answers

Answered by anitapatil777888
1

Answer:

hiiiiiiiiiiiiiiiiiii


arunbabu43916: anyone answer
Answered by dreamrob
3

In the given program : s*s++ is used to get the starting digits of the square.

If we consider :

d = s % 10;

if(d == 5)

{

  s = s/10;

  printf("\n Square = %d%d",s*s++,d*d)

}

If s = 25

So, d = s % 10 = 25 % 10 = 5

if(d == 5)     //true , so if block will execute.

s = s / 10 = 25 / 10 = 2

So, finally s = 2

s++ = 2 + 1 = 3

So, s*s++ = 2 * 3 = 6

Same program in C++

#include<iostream>

using namespace std;

int main()

{

int n;

cout<<"Enter Number : ";

cin>>n;

if(n%10==5)

{

 cout<<"Square = "<<n*n;

}

else

{

 cout<<"Least significant digit is not 5 \nIt is "<<n%10;

}

return 0;

}

Similar questions