Sponsored Links

 

 

 

INTRODUCTION TO C PROGRAMMING CE00312-1

Source: www.soc.staffs.ac.uk
Topic: C Programming


Short Desciption:
Page 1 INTRODUCTION TO C PROGRAMMING CE00312-1 TUTORIAL / PRACTICAL No. 3 1. Implement each of the following functions a) - d) and write a testbed program to call each function.

 

Content Inside:
Page 1 INTRODUCTION TO C PROGRAMMING CE00312-1 TUTORIAL / PRACTICAL No. 3 1. Implement each of the following functions a) - d) and write a testbed program to call each function. The testbed accepts a character to select a function, reads values required to test the function, calls the function which calculates the result, returning it to main() from where it is printed. This is performed repeatedly until q (for quit) is input. i. The testbed should be implemented first and should initially output "function x not yet implemented" for each valid selection x, or report erroneous selections. ii. Add the following functions one at a time to the testbed. Note that all input and output must occur in the testbed i.e. in main(). a) A function mult(x,y) which returns the value of x*y where x and y are integers. b) A function find_abs(x) which returns the absolute value of the double precision floating point argument x. e.g. find_abs(3.0) produces 3.0, find-abs(-3.0) gives 3.0 c) A function fact(x) which returns x! ( x factorial )  where x is an integer d) A function power(x,y) which returns x to the power of y, where x is a floating point and y is a positive integer e.g. power(3.0,4)  gives 81.0 i.e. 3.04. Hint.use repeated multiplication. iii. Finally, add a function to print a menu for the selections and incorporate this in your program. You should incorporate the switch statement and take care when processing characters. You should refer to Lecture 3 to remind yourself of how to input and process characters, paying attention to the return key. Comments should be used throughout. Your tutor will explain in the tutorial how to do "double reads" when character and integer input needs to be mixed. "Build a little - test a little" is a recommended approach to programming. Namely modify programs slightly, then recompile. Yes, more compilations are needed - but you dont get "swamped" with ...

 

add to Google Reader add to Google Bookmark add to bloglines add to newsgator add to FURL add to digg add to webnews add to Netscape add to Yahoo MyWeb add to spurl.net add to diigo Bookmark newsvine Bookmark del.icio.us Bookmark @ SIMPIFY Bookmark MISTER WONG Bookmark Linkarena Bookmark icio.de Bookmark oneview Bookmark folkd.com Bookmark yigg.de Bookmark reddit Bookmark StumbleUpon Bookmark Slashdot Bookmark blinklist Bookmark technorati add to blogmarks add to blinkbits add to ma.gnolia add to smarking.com add to netvouz add to co.mments add to Connotea add to de.lirio.us

 

Related PDF Files

Part IA Computing Course Tutorial Guide to C++ Programming


Topic: C Programming

Tutorial Guide to C++ Programming. Roberto Cipolla. Department of Engineering. University of Cambridge. September 1 2004 ...

CS349/SE382 A1 C Programming Tutorial


Topic: C Programming

CS349/SE382 A1 CProgramming Tutorial Dierences fromC++ Dynamic Memory Dynamic Memory: Dynamic Memory Allocation I memory is allocated usingmalloc() I malloc() takes the number of ...

C/C++ Programming Style Guidelines


Topic: C Programming

C/C++ Programming Style Guidelines Table of Contents Introduction File Contents File Format ... With luck, a good style guide can encourage better programming habits. To that end, all C++ programmers should ...

C Language Tutorial


Topic: C Programming

C Language Tutorial. Version 0.042. March 1999. Original MSDOS tutorial by. Gordon Dodrill Coronado Enterprises. Moved to Applix by Tim Ward ...

The Objective-C Programming Language


Topic: C Programming

object-oriented programming. Objective-C is defined as small but powerful set ... manual for C presented in The C Programming Language by Brian W. Kernighan ...

 

Sponsored Links