Introduction to Computer (1) Course Examination Paper
Applicable Major: Computer Science and Technology Examination Method: Computer Examination Time: 20 12 12.
ClassNo. 125702 19 Name: Li Zhiwei Achievement.
Score Registration (to be filled in by the marking teacher)
The title is one two three four
mark
Instructions for candidates:
Submit test results:
Programming questions, paste the program source code to the lower end of the corresponding topic in the test paper, and name the file with the name of the student number.
Choose or fill in the blanks (2 points for each small question ***20 points)
1. A complete computer system should include (b).
A. Host and external devices B. Hardware system and software system
C. Operating system and application software system D. Input devices and output devices
2. The following statement is correct.
A loop formed by a. do-while statement cannot be replaced by a loop formed by other statements.
The loop formed by the B.do-while statement can only be exited by the break statement.
C. When the expression after while is non-zero, the loop consisting of do-while statements ends.
D. When the expression after while is zero, the loop consisting of do-while statements ends.
3. The operator whose operand must be an integer in C language is.
A.%=
B./ C. =
D.*
4. Translate programs written in high-level languages into machine language programs by two translation methods.
A. Compilation and interpretation B. Compilation and compilation
C.d. interpretation and compilation
5. The central processing unit of a microcomputer system comprises
A. Memory and controller B. Main memory and arithmetic unit
C. controller and arithmetic unit D. internal memory. Controller and arithmetic unit
6. In C language, the following symbols cannot be used as user identifiers.
A._256
B.3 Charles C.
abc D. ds3
7. The programming language that the computer can directly execute is.
A. Basic
C. Machine language D. Assembly language
8. The following relationship that can correctly express a≥ 10 or a≤0 is _ _ _ _ _.
A.a>= 10 or a< = 0b.a > = 10 | a & lt; =0
C.a & gt= 10 | | a & lt; = 0d . a & gt; = 10 & amp; & ampa & lt=0
9. In C language, 1 means the logical value "true" and 0 means the logical value "false".
10. The binary digit represented by 1 byte in the microcomputer is 8 bits.
Two. Complete the following questions
1. The following program is used to read five integers. When the data n read by the program is a positive integer, the number will be displayed. Please supplement the program. (5 points)
# include & ltstdio.h & gt
void main()
{ int i,n;
for(I = 1; I < = 5; i++)
{
printf(" please enter n:");
scanf( "%d ",& ampn);
If (n & gt0)printf ("Integer:% d", n);
}
Printf ("The program is over! \ n ");
}
2. Rewrite the next program to input any characters from the console. If it is uppercase, it will be converted to lowercase. If it is lowercase, it is converted to uppercase, and other characters are output as they are. (10)
# include & ltstdio.h & gt
void main()
{ char c 1,C2;
c 1 = ' A ';
C2 = c 1+32;
printf("%c\n ",C2);
}
Answer code:
# include & ltstdio.h & gt
void main()
{ char c 1,C2;
Printf ("Please enter a character:");
scanf("%c ",& ampc 1);
if(c 1 & lt; = ' z ' & amp& ampc 1 & gt; ='a ')
{ C2 = c 1-32;
Printf ("capital letter: %c\n\n", C2); }
else if(c 1 & lt; = ' Z ' & amp& ampc 1 & gt; ='A ')
{ C2 = c 1+32;
Printf ("lowercase letters: %c\n\n", C2);
}
other
Printf ("original character: %c\n\n", c1);
}
3. What's wrong with the following procedures? Please correct it. (10)
# include & ltstdio.h & gt
void main()
{short x, y, z;
x = 200
y = 300
z = x * y;
printf("%d\n ",z);
}
Answer code:
# include & ltstdio.h & gt
void main()
{ int x,y,z;
x = 200
y = 300
z = x * y;
printf("%d\n ",z);
}
4. Read the program to supplement the function of the program. (10)
Enter the year at will from the keyboard to judge whether it is a leap year. If it is a leap year, the output is "leap year", otherwise the output is "not leap year". It is known that one of the following conditions is leap year: it can be divisible by 4, but not by 100. Divisible by 400.
# include & ltstdio.h & gt
void main()
{ int year,flag
printf(" enter year:");
Scanf("%d ",& year);
If ((year% 4 = 0 & amp& amp year% 100! = 0)| | Year %400=0)
{ flag = 1;
}
other
{ flag = 0;
}
if ( flag= 1)
{
Printf ("This year is a leap year \ n");
}
other
{
Printf ("not a leap year \ n");
}
}
Third, write the program and debug the program to run correctly.
1. Write a program to input the price of a computer from the keyboard, and then output the price after a 30% discount. (15)
Answer code:
# include & ltstdio.h & gt
# include & ltwindows.h & gt
int main()
{
Floating a, b;
Printf ("Enter computer price:");
scanf("%f ",& ampa);
b = 0.7 * a;
Printf ("The price after 30% discount is %. 1f\n\n", b);
System ("suspended");
Returns 0;
}
2. Enter a three-digit number from the keyboard and find the sum of each number. For example, the three-digit input is 385, and the output result is 3+8+5 =16; (15)
Answer code:
# include & ltstdio.h & gt
# include & ltwindows.h & gt
# include & ltstring.h & gt
int main()
{
char a[3];
intb,c,d,e;
Printf ("Please enter three digits:");
scanf("%s ",a);
b = a[2]-' 0 ';
c = a[ 1]-' 0 ';
d = a[0]-' 0 ';
e = b+ c+d;
Printf ("The sum of all numbers is: %d\n\n", e);
System ("suspended");
return0
}
3. A Japanese middle school student found a wonderful "theorem" and asked Professor Jiazi to prove it, but Professor Jiazi could do nothing about it, so he produced Jiazi conjecture. The content of the conjecture is: divide any natural number by 2 if it is even, and multiply it by 3 plus 1 if it is odd to get a new natural number. Continue to calculate according to the above rules. After several times, the result is 1. Please. (15)
Answer code:
# include & ltstdio.h & gt
void main()
{ int a;
Printf ("Enter natural number:");
scanf("%d ",& ampa);
if(a%2== 1)
a = a * 3+ 1;
And (a! = 1)
{
a = a/2;
}
Printf ("Result: %d\n", a);
}
I come from experimental college. This is the end of 20 12 of our freshman year. I hope it helps. The answers in it are all written by myself and can be ignored.