(C syntax) input a number and output its absolute value. The syntax is a number.
Knowledge point:
If statement
Content: enter a number to output its absolute value.
Input description:
One integer in one row
Output description:
One integer in one row
Input example:
-3
Output example:
3
# Include <stdio. h> int main () {int a; scanf ("% d", & a); if (a <0) {a =-;} printf ("% d \ n", a); return 0 ;}
Entry C language: enter any integer on the keyboard and then output its absolute value.
Method 1:
// Use mathematical functions
# Include <stdio. h>
# Include <math. h>
Void main ()
{
Int;
Scanf ("% d", & );
Printf ("% d \ n", abs ());
}
Method 2:
// Judge
# Include <stdio. h>
Void main ()
{
Int;
Scanf ("% d", & );
If (a> = 0)
Printf ("% d \ n", );
Else
Printf ("% d \ n",-);
}
C language program 1 input a real number and output its absolute value 21! + 2! + ...... + 10! And the operation to calculate the factorial is defined as function 3.
L, kpki [P', k0yhj0'; l-p; '. piklp ';