Replace the ??? in the following code so that the program can correctly compute
the square of the number entered by the user.
Assume that the input number is always an 8-digit positive integer.
* Note that the output format is always 16-digit wide with space prepended if needed.
For example,
(11111111)^2 = _123456787654321
_ is a space character.
#include <stdio.h>
/* 2016/09/22 */
int first4(int x){
return x/10000;
}
int last4(int x){
/* The operator % in C computes the remainder after division.
For example, the answer of 23%7 will be 2.*/
return x%10000;
}
int first8(int x){
return x/100000000;
}
int last8(int x){
return x%100000000;
}
int shift4(int x){
return x*10000;
}
int main(void){
int x;
int a, b;
int c1, c2, c3;
/* Assume that the input is always an 8-digit positive integer. */
scanf("%d", ???);
a = first4(x);
b = last4(x)
c3 = ???;
c2 = ???;
c1 = ???;
printf("%4d%08d%04d", ???, ???, ???);
/* %04d will display a 4-digit number and add 0 as padding before the number if necessary */
return 0;
}
x can be expressed by a*10000 + b .The square of x can be expressed as a*a*100000000 + 2*a*b*10000 + b*b .The input is always an 8-digit positive integer
the square of input .
Note that you do not need to print ‘\n’ at the end of the output.