Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Jack H.Integration and automation of manufacturing systems.2001.pdf
Скачиваний:
86
Добавлен:
23.08.2013
Размер:
3.84 Mб
Скачать

page 66

• Written for turbo ‘C’

3.10 PRACTICE PROBLEMS

1.What are the basic components of a ‘C’ compiler, and what do they do?

2.You have been asked to design a CAD program which will choose a bolt and a nut to hold two pieces of sheet metal together. Each piece of sheet metal will have a hole drilled in it that is the size of the screw. You are required to consider that the two pieces are experiencing a single force. State your assumptions about the problem, then describe how you would produce this program with a Top Down design.

3.What are some reasons for using ‘C’ as a programming language?

4.Describe some of the reasons for Using Top-Down Design, and how to do it.

3.11 LABORATORY - C PROGRAMMING

Purpose:

To practice programming in ‘C’.

Overview:

C programming is an essential tool for developing automated systems. It can be used to develop customized applications for communication and data handling.

Pre-Lab:

Review C programming.

In-Lab:

page 67

1.Start up the linux machine, and get X-windows running.

2.Create a new directory with ‘mkdir src’, and then enter the directory with ‘cd src’.

3.Use the ‘kedit test.c’ text editor to enter the program below.

#include <stdio.h>

main(){

char work[20];

int i, start, stop;

printf(“enter a start value:”); scanf(“%d”, &start); printf(“enter a stop value:”); scanf(“%d”, &stop);

for(i = start; i <= stop; i++){ printf(“value %d \n”, i);

}

}

4.Compile the program with ‘cc test.c -o test’. Run the program with ‘./test’.

5.Modify the program to only print every second number.

6.Write a number guessing game that will randomly pick a number between 1 and 100. The user can then guess the number, and the computer will give clues ‘high’ or ‘low’ until the value is guessed. The program will then quit. Use a top-down programming approach.

Submit (individually):

1. All program listings, with comments.