Professional Documents
Culture Documents
AIM OF EXPIREMENT
ALGORITHM -
: WAP to read an array of elements and print the same in the reverse order along with their
addresses using pointer.
1. Start
5.Now we have accepted element one by one using for loop and scanf statement .
6. Increment pointer variable so that it will then point to next element of array.
7. After accepting all elements store address of last element inside pointer variable.
8. Again using reverse for loop and printf statement print an array
9. End
PROGRAM CODE
#include
#include<conio.h>
#define MAX 30
void main() {
int size, i, arr[MAX];
int *ptr;
ptr = &arr[0];
printf("\nEnter the size of array : ");
scanf("%d", &size);
printf("\nEnter %d integers into array: ", size);
for (i = 0; i < size; i++) {
scanf("%d", ptr);
ptr++;
}
ptr = &arr[size - 1];
Practical 8.2: Write a function code that is returning pointer to the larger value out of two passed
values.
ALGORITHM -
1. Start
2. Declare a user defined function using pointer to store address of two variables to find
larger no. from them
3. In function definition if num1 is greater than num2 return num1 to main else return
num2 in main function .
4. In main function declare and initialize two variable and take input of these two
variable from user using scanf
5. by calling the find larger function using pointer and compare the address of two
variable given by user
6. Print the result which number is greater
7. stop
Program code :
#include <stdio.h>
int* findLarger(int*, int*);
void main()
{
int a=0;
int b=0;
int *result;
result=findLarger(&a, &b);
printf(" The number %d is larger. \n\n",*result);
}
OUTPUT :
LEARNING OUTCOMES
● Apply various constructs, loops, functions to solve mathematical and scientific problem.
● Design and develop modular programs for real world problems using control structure
and selection structure.