Date 030807

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Date 030807 as PDF for free.

More details

  • Words: 1,239
  • Pages: 23
'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

Dept. of CS&Engg., IIT Kharagpur

$ 1

Tutorial & Laboratory  

Programming & Data Structure: CS11001/19001  



Section - 9/C 





DO NOT POWER ON THE MACHINE Department of Computer Science and Engineering I.I.T. Kharagpur Autumn Semester: 2007 - 2006 (03.08.2007) &

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

Dept. of CS&Engg., IIT Kharagpur

$ 2

Download Download the file date030807.ps from Programming & Data Structures ... of http://www.facweb.iitkgp.ernet.in/∼goutam View the file using the command kghostview & or ggv & &

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

Dept. of CS&Engg., IIT Kharagpur

$ 3

Submission of an Assignment

• There will be no hard copy printout for the sessional work. • You will submit the C program by ftp.

&

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

Dept. of CS&Engg., IIT Kharagpur

$ 4

Sessional Evaluation

• Correctness of program! • Regularity of work. • Programming style. • Program debugging and testing (by the student). &

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

Dept. of CS&Engg., IIT Kharagpur

$ 5

Note

If program plagiarism is detected, both the source of the copy and the destination of the copy will be awarded zero (0) in that experiment.

&

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

Dept. of CS&Engg., IIT Kharagpur

$ 6

Program Header

• Each program should have a header containing Section (9/C), Machine No., Roll No., Name, Assignment No. and a short description of the assignment. &

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

Dept. of CS&Engg., IIT Kharagpur

$ 7

File Name Convention • The file name will be CmmAA.c, where ‘C’ is for the section 9, ‘mm’ is the machine number and ‘AA’ is the assignment number e.g. C0604.c is the C program file from section 9, machine number ‘06’, for the 4th assignment.

&

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

Dept. of CS&Engg., IIT Kharagpur

$ 8

How to Prepare the Submission File • Every input data is also to be printed in the program. • Test your program to satisfy yourself before submission; then do the following: [Let the program file be C0604.c]

&

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

Dept. of CS&Engg., IIT Kharagpur

$ 9

Submission File (cont.) • Copy C0604.c to C0604.prn : $ cp C0604.c C0604.prn • Let there be five (5) sets of test input. Collect five sets of output in a file by executing ./a.out five times in the following way. $ ./a.out >> C0604.out

&

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 10

Submission File (cont.) • Append the output file to the print file: $ cat C0604.out >> C0604.prn

&

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 11

Submission File • You may see the content of C0604.prn by: $ cat C0604.prn | less • If you are satisfied, submit C0604.prn by ftp. • If you are not satisfied, remove both C0604.out and C0604.prn, $ rm C0604.out C0604.prn Fix the error and repeat the process. &

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 12

Submission by ftp

$ ftp 10.3.19.55 Connected to 10.3.19.55 (10.3.19.55). 220 pclabII102 FTP server (Version wu-2.6.2-5) ready. Name (10.3.19.55:.....): pds09 Password: ******* 230 User pds07 logged in. Remote system type is UNIX. Using binary mode to transfer files. > cd assignment04 250 CWD command successful. ftp> put C0604.prn &

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 13

Submission by ftp ftp> put C0604.prn local: C0604.prn remote: C0604.prn 227 Entering Passive Mode (...............) 150 Opening BINARY mode data connection for bat. 226 Transfer complete. 26 bytes sent in ......... secs (....... Kbytes/sec) ftp> bye ............ $ &

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 14

C Program, Output & Print Files

&

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 15

C program for the following function   2  x +9   

if x < 0,

f (x) =  x4 + 3x2 + 7 if 0 ≤ x < 20,     12x + 7

otherwise

Test the program with the following set of data. {−1.0, 0.0, 20.0, −0.99, +0.99, 19.99, 20.001} &

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 16

C Program: Header : C0604.c /****************************************** * Section : C/9 * * M/c No. : 06, Roll No. : 20MB3007, * * Name : Arya Bhatta, * * Assignment No. : 04, * * Description : Program to calculate a * * given function. * ******************************************/ &

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 17

int main() { float x, fx, temp ;

printf("Enter the value of x : ") ; scanf("%f", &x) ; if (x < 0.0) fx = x * x + 9.0 ; else if (x < 20.0) { temp = x * x ; fx = temp * (temp + 3.0) + 7.0 ; } else fx = 12.0 * x + 7.0 ; printf("\nf(%f) = %f\n", x, fx) ; }

&

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 18

Creation of Output File $ ./a.out >> C0604.out -1.0 $ ./a.out >> C0604.out 0.0 $ ./a.out >> C0604.out 20.0 $ &

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

Dept. of CS&Engg., IIT Kharagpur

Output file: C0604.out

$ 19

$ cat C0604.out | less Enter the value of x : f(-1.000000) = 10.000000 Enter the value of x : f(0.000000) = 7.000000 Enter the value of x : f(20.000000) = 247.000000 Enter the value of x : f(-0.990000) = 9.980100 &

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 20

Enter the value of x : f(0.990000) = 10.900896 Enter the value of x : f(19.990000) = 160886.031250 Enter the value of x : f(20.000699) = 247.011993

&

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 21

Creation of Print File $ cp C0604.c C0604.prn $ cat C0604.out >> C0604.prn $ cat C0604.prn | less

&

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

Print File: C0604.prn

/****************************************** * Section : D/2 * ............................. int main() { float x, fx, temp ; ............................. printf("\nf(%f) = %f\n", x, fx) ; } Enter the value of x : f(-1.000000) = 10.000000 .............................

&

$

Dept. of CS&Engg., IIT Kharagpur 22

%

'

PDS Tut. & Lab.: II (CS 11001/19001): Section 9

$

Dept. of CS&Engg., IIT Kharagpur 23

Assignment Programs

• Create a subdirectory assignment07 under your home directory:

$ mkdir assignment07 • Change your current directory to assignment07:

$ cd assignment07 • Execute emacs and create files of assignment programs under the subdirectory assignment07:

$ emacs &

&

%

Related Documents

Date 030807
November 2019 21
Tut 030807
November 2019 24
Date
June 2020 29
Date
June 2020 33