You are on page 1of 3

NFC Institute of Engineering&Fertilizer

Research Faisalabad

Department of Electrical Engineering


Fourth Semester
Course Title:
Data Structure & Algorithms (EE-232)
Topic:
Lab Assignments
Submitted To:
Dr. Salman Arain
Submitted By:
Hafeez Ali
Roll.No:
18-ELE-43
Reg.#:
2018-UET-NFC-FD-ELECT-43
Lab.No.3
PROGRAM USING FUNCTION, POINTER AND STRUCTURE
Task#1
Write a code to declare a function.
Code:
#include <stdio.h>
int max(int num1, int num2); //Declaring a function at the start of the program.

int max(int num1, int num2) {


int result;

if (num1 > num2)


result = num1;
else
result = num2;

return result;
}

Task#2
Write a code to assign a pointer.
Code:
#include <stdio.h>
int main () {
int var = 20;
int *ip;

ip = &var;

}
Task#3
Write a code to define a structure.
Code:
#include <stdio.h>

struct Books {
char title[50];
char author[50];
char subject[100];
int book_id;
};

int main( ) {

struct Books Book1;


struct Books Book2;
}

Conclusion:
In this lab, I came to the basic programming algorithms in data structures
such as:
1. Functions
2. Pointers
3. Structures

You might also like