Experiment 2-1-5 Assign the square of x to y (5 points)

The assumed xvalue is the 3calculated xsquare and assigned to y, and the sum value “y = x ∗ x”和“x ∗ x = y”is output in the form of respectively.xy

Input format:

No input for this question

Output format:

x=3The result of the substitution is output in the following format :

y = x * x
x * x = y

Code:

# include <stdio.h>
# include <stdlib.h>

int main(){
    
    
    int x = 3,y;
    y = x * x;
    printf("%d = %d * %d\n",y,x,x);
    printf("%d * %d = %d\n",x,x,y);
    return 0;
}

Submit screenshot:

Insert picture description here

Problem-solving ideas:

The test point of this question is to output two lines in a similar format. Pay attention to \nthe addition of a newline at the end . Use %da placeholder of integer type to indicate that the output number type is an integer!

Guess you like

Origin blog.csdn.net/weixin_43862765/article/details/114363250