computer programming- lecture 10

Download Computer Programming- Lecture 10

Post on 03-Dec-2014

5.632 views

Category:

Education

5 download

Embed Size (px)

DESCRIPTION

Arrays, Functions and Structures

TRANSCRIPT

  • 1. Lecture 10 Arrays, Functions & StructuresTCP1231 Computer Programming I 1

2. Objectives To Learn about functions and arrays Explore how to declare and manipulate arrayswith functions Explore how to declare and manipulate structureswith functions Become familiar with functions, arrays, andstructures.TCP1231 Computer Programming I 2 3. Functions Revisited(User Defined Function) Two components of a function definition Function declaration (or function prototype) Shows how the function is called Must appear in the code before the function can be called Syntax: Type_returned Function_Name(Parameter_List); //Comment describing what function doesTCP1231 Computer Programming I 3 4. Functions Revisited(User Defined Function) Function definition Describes how the function does its task Can appear before or after the function is called Syntax: Type_returned Function_Name(Parameter_List) {//code to make the function work }TCP1231 Computer Programming I4 5. #include using namespace std; int p(int x, int n) {int temp=1;int p(int x, int n); Function for (int i=1; i > no; int temp=1; cout "; } cin >> n; cout "; cin >> rec.mark; cin.ignore(); return rec; }TCP1231 Computer Programming I 11 12. #include To read info about three studentsusing namespace std;void printing(students rec){struct students{cout