C语言答案(国外英文资料)
C语言答案(国外英文资料)
Basic input/output functions
Write a basic function:
To assign values to six variables, the value of the variable is printed on the screen.
The variables are 10, -10, 40, 000, a, 3.14, and hello
# include < stdio, h >
Void main ()
{
Int b, c;
Long int d;
Char e, STR [5];
Float f;
Scanf (" % d, % d, % d, % c, % s, % s).
Printf (% d, % d, % c, % s, % f \ n, b, c, d, e, STR, f);
}
Basic data types and their operations
Write a program that requires the user to enter two integers a, b, to read the value that the user entered from the keyboard, and then print out the two Numbers
And the difference, the product, the quotient and the remainder and the average. The sum, difference, and remainder are output by integer, the product is output with long plastic, the quotient and the average are output by float.
Methods a
The main ()
{
Int x, y, he, cha, yu;
Long int ji;
Float sang, business;
Printf (" please input your two numbles! \ n ");
Scanf (% d, % d, &x, &y);
He = a + b;
Cha = a - b;
Yu = a % b;
So, ji equals (long int) a + b;
Sang a/b = 1.0 *;
Average = (a + b) / 2.0;
Printf (" \ nhe = % d, cha = % d, yu = % d), and "sang = % f", and "s = % f \ n", "he", "cha", "yu", "sang", "(")";
}
Method 2
# include < stdio, h >
Int plus (int q, int w)
{
Int plu;
Plu = q + w;
Return (plu);
}
Int cut (int a, int b)
{
Int cu;
Cu = a - b;
Return (cu);
}
Int thu (int r, int t)
{
Int th;
Th = r * t;
Return (th);
}
Float SAN (int u, int p)
{
Float sa;
Sa = u/p;
Return (sa);
}
The main ()
{
Int x, y, he, cha, ji;
Float sang;
Printf (" please input your two numbles! \ n ");
Scanf (% d, % d, &x, &y);
He = plus (x, y);
Cha = cut (x, y);
Ji = thu (x, y);
Sang = SAN (x, y);
Printf (" \ n he = % d, cha = % d, ji = % d, sang = % f \ n ", he, cha, ji, sang);
}
Program control structure - branch structure
Enter three integers, which are stored in the variable a, b, and c, and try to program the output of three variable values from big to small.
The main ()
{
Int x, y, z, t;
Scanf (% d %