Lab Exercise 6 - Functions

  • Uploaded by: rushdulla muaz
  • 0
  • 0
  • May 2020
  • 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 Lab Exercise 6 - Functions as PDF for free.

More details

  • Words: 412
  • Pages: 2
Introduction to Programming

Advance Certificate in Information Technology Introduction to Programming Lab Exercise 6 – Using Functions Write C codes for the following problems. Use plenty of whitespace to make your code readable, use reasonable (not one-character) variable names, and include frequent comments explaining your code. Use the following comment block at the beginning of your source code: /*****************************************************/ /* Filename: <provide here the file name */ /* Name: <Student Name */ /* Date: <16 Oct 2009 */ /* Lab Exercise: */ /*****************************************************/

Questions 1. Write C programs to perform the following tasks Input two numbers and work out their sum, product and minimum and maximum from the two numbers. Each of the tasks should be done in separate functions. For example finding sum of the two numbers should be done in a separate function. Likewise finding average should be done in a separate function too. Printing result for each of the problem should be done in the main function.

2. Write a program to print the following pattern in either ascending order or descending order using a function. The program should be able to read the type of character used in the pattern, number of rows and a choice for choosing ascending order or descending order. 3. Main function should do all the reading from user and a separate function should create to make the pattern. * ** *** **** ***** ******

Tutor : Shaaman Abdulla Masood

1

Introduction to Programming

4. Write a Program in C to find the Fibonacci series (in Fibonacci series every term is the sum of its preceding two terms). Finding Fibonacci series should be done in a separate function Example: Enter No. of elements(>3):7 0 1 1 2 3 5 8

5. Write a program to print multiples of a given number up to 12. Multiplication table should printed using a separate function. 6. Write a program to read two number as base and exponent and the power of the integer base number. For example (3, 4) = 3 * 3 * 3 * 3. Validate the two input number to check that the exponent is a positive, nonzero integer, and base is an integer. Calculation required to find the power of the integer should be done in a separate function. 7. Write a program to read marks for 7 subjects and find the total and average. Use at least two functions to solve the problem.

Tutor : Shaaman Abdulla Masood

2

Related Documents

Exercise # 6
June 2020 6
Exercise 6
November 2019 12

More Documents from ""