Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Lab # 3

PROGRAM USING FUNCTION, POINTER AND STRUCTURE


Task 1:
Write a code to declare a function.
Code:
#include <stdio.h>

int max(int numl, int num2), //Declaring a function at the start of the program.

int max(int numl, int num2)


{

int result;

if (numl > num2)

result = numl ,

else

result = num2;

return result;

Task 2:

Write a code to assign a


pointer.

Code:
#include <stdio.h>

int main 0

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 Bookl,

struct Books Book2;

Conclusion:
From this lab, I learned the basic programming algorithms in data structures

such as:

1. Functions
2. Pointers
3. Structures

You might also like