You are on page 1of 5

Laboratory 3

1. Questions
1. Write a program to find biggest among three numbers using pointer.
2. Write a program to find the sum of all the elements of an array using pointers
3. Write a program to sort a list of string words using an array of pointers.

2. Introduction
In this lab the student will learn about conditional statements, how to use pointers.

3. Program
1) To find biggest among three numbers using pointer.
2) Program to find the sum of all the elements of an array using pointers
3) Program to sort a list of string words using an array of pointers.

#include<stdio.h>
void main()
{
    char *T;
    int I,J,K;
    char *ARRAY[5]={“SUNIL”,”ANIL”,”DILIP”,”JAY”,”BHARAT”};
    clrscr();
    for(I=0;I<5;I++)
    {
       printf(“%s \t”,ARRAY[I]);
    }
    printf(“\n”);
    for(I=0;I<4;I++)
    {
      for(J=0;J<4-I;J++)
      {
 K=strcmp(ARRAY[J],ARRAY[J+1]);
 if(K>0)
 {
   T=ARRAY[J];
   ARRAY[J]=ARRAY[J+1];
   ARRAY[J+1]=T;
 }
      }
    }
    for(I=0;I<5;I++)
    {
       printf(“%s \t”,ARRAY[I]);
    }
getch();
}
4. Presentation of results
1) Output for first program

2) Second program

3) Third program
5. Conclusion

1. Here we learned to write a program to find biggest among three numbers using
pointer, to find the sum of all the elements of an array using pointers and a
program to sort a list of string words using an array of pointers.

You might also like