C Language Programming Instructions and Exercises for Computer Experiment (2nd Edition) Reference answer (For internal reference only) Preliminary Programming of Experiment 1C Language I. Experimental Purpose (1) Understand the basic operating methods of the computer system used and learn to use the system independently. (2) Understand how to edit, compile, connect and run a C program on the system. (3) By running a simple C program, we can get a preliminary understanding of the characteristics of C program. (4) Under the guidance of teachers, learn to use Judge Online experimental system. II. EXPERIMENTAL CONTENTS 1. Run the first C program slightly 2. Submit a program to calculate a+b function in JudgeOnline system slightly 2 Experiment 2 Basic Data Types, Operations and Expressions I. Experimental Purpose (1) Master C language data type, familiar with how to define an integer and real variables, and how to assign them. (2) Grasp the law of assignment between different types of data. (3) Learn to use the arithmetic operators of C and the expressions containing these operators, especially the self-adding (++) and self-decreasing (--). Operator usage. (4) Familiar with the process of editing, compiling, connecting and running C programs. II. EXPERIMENTAL CONTENTS [Title 1117: Definition of variables, completing procedures as required] Here is a program that can be run, but some statements are missing. Please follow the prompt on the right to supplement the complete missing statements. # include "stdio.h" Main () { Int a, b; /* Define integer variables A and b*/ Int i, j; /* Define real variables I and j*/ A=5; B=6; I = 3.14; J = i*a*b; Printf ("a=% d, b=% d, i=% f, j=% f n", a, b, i, j); } [Specific operation steps] (1) Complete the code; (2) Running on TC or VC++; (3) Submitted on Judge Online experimental system; [Title 6568: Display specified characters on the display screen] A program is required to display the following contents on the display screen (all half-corner characters, without spaces): C:\ABC.TXT [Tip] Pay attention to the use of escape characters in programs. Reference procedure: # include "stdio.h" Main () {printf ("C:\\ ABC. TXT");} 3 [Title 1118: Assignment Expressions and Assignment Statements, Write the Results of Programming] Read the following program and write out the results: # include "stdio.h" Main () {float a; Int b, C; Char D, E; A=3.5; B=a; C=330; D=c; E='\141'; Printf ("% f,% d,% d,% c,% c", a, b, c, d, e); } The results are as follows: 3.500000,3,330,J,a [prompt] assignment statement has the function of type conversion, but it may change data. [Title 1119: Basic operations, write out the results of program operation] Read the following program and write out the results: # include "stdio.h" Main () {int a, b, c; Float d = 15, e, f; A=35%7; B=15/10; C=b++; E=15/10; F=d/10; Printf ("% d,% d,% d,% f,% f", a, b, c, d, e, f); } The results are as follows: 0,2,1,15.000000,1.000000,1.500000 [prompt] dividing, dividing, dividing, dividing, dividing, dividing, dividing, dividing, dividing, dividing, dividing, dividing, dividing, dividing and dividing. 4 Experiment 3 Basic Input and Output I. Experimental Purpose (1) Proficiency in putchar, getchar, printf and scanf functions. (2) Master the input and output methods of various types of data, and can correctly use various format converters. II. EXPERIMENTAL CONTENTS [Topic 1126: Character input and output] After a character is input by keyboard, the character is output on the screen. [First set of self-test data] [Keyboard input] A [Correct output] A [Second set of self-test data] [Keyboard input] ++ [Correct output] + Reference procedure: # include "stdio.h" Main () {char ch; Ch = getchar (); Putchar (CH); } [Topic 1127: Computational addition] Programming implements that an additive formula is input by keyboard and the correct result is output.(Both additives are integers) [First set of self-test data] [Keyboard input] 10+20 [Correct output] 30 [Second set of self-test data] [Keyboard input] -15+60 [Correct output] 45 Reference procedure: # include "stdio.h" Main () {int a, B; Scanf ("% d%* c% d", & a, & b); Printf ("% D", a + b); } [Topic 1014: Finding Circle Area] The radius r of the circle is input by the keyboard. Please calculate the area of the circle.(Note: Pi is 3.14159, the result is two decimal digits reserved; in addition, the program only To be able to output the correct answer for R in the range of 0 to 10,000) [Firs

docxDoc C-Language Programming Experiments

Professional Docs > Common > Other > Preview
38 Pages 0 Downloads 73 Views 3.0 Score
Tips: Current document can only be previewed at most page8,If the total number of pages in the document exceeds page 8,please download the document。
Uploaded by admin on 2019-10-15 12:09:41
Rate
You can enter 255 characters
What is my domain?( answer:www.45doc.com )
comments
  • No comments yet