using codeblocks
------------------------------------------------------------------------------------------------------
//program to pick the greatest number using pointer
#include <stdio.h> //header file
int main()
{
int a[100]; //array declaration
int i,max;
int total; //variables declaration
int *p; //pointer declaration
printf("enter value of total\n");
scanf("%d",&total); //input of total value of array
printf("enter elements of array\n");
p=a; //storing of base address to pointer
for(i=0;i<total;i++) //execution of loop
{
printf("enter value for location=%d\t",i);
scanf("%d",p+i); //input of element using pointer. here array's base address is used for input
//It gets input using address starting from base location 0.
//It goes on increasing (address) as the loop moves ahead.
}
max=*(p+0); //It stores value stored in location 0
for(i=0;i<total;i++)
{
if(max<*(p+i)) //comparison takes place
{
max=*(p+i); //assigning value
}
}
printf("max value=%d",max); //display of maximum value
return 0;
}
--------------------------------------------------------------------------------------------------------
using turbo c++
-------------------------------------------------------------------------------------------------------
//program to pick the greatest number using pointer
#include <stdio.h> //header file
#include<conio.h>
int main()
{
int a[100]; //array declaration
int i,max;
int total; //variables declaration
int *p; //pointer declaration
printf("enter value of total\n");
scanf("%d",&total); //input of total value of array
printf("enter elements of array\n");
p=a; //storing of base address to pointer
for(i=0;i<total;i++) //execution of loop
{
printf("enter value for location=%d\t",i);
scanf("%d",p+i); //input of element using pointer. here array's base address is used for input
//It gets input using address starting from base location 0.
//It goes on increasing (address) as the loop moves ahead.
}
max=*(p+0); //It stores value stored in location 0
for(i=0;i<total;i++)
{
if(max<*(p+i)) //comparison takes place
{
max=*(p+i); //assigning value
}
}
printf("max value=%d",max); //display of maximum value
getch();
return 0;
}
------------------------------------------------------------------------------------------------------
//program to pick the greatest number using pointer
#include <stdio.h> //header file
int main()
{
int a[100]; //array declaration
int i,max;
int total; //variables declaration
int *p; //pointer declaration
printf("enter value of total\n");
scanf("%d",&total); //input of total value of array
printf("enter elements of array\n");
p=a; //storing of base address to pointer
for(i=0;i<total;i++) //execution of loop
{
printf("enter value for location=%d\t",i);
scanf("%d",p+i); //input of element using pointer. here array's base address is used for input
//It gets input using address starting from base location 0.
//It goes on increasing (address) as the loop moves ahead.
}
max=*(p+0); //It stores value stored in location 0
for(i=0;i<total;i++)
{
if(max<*(p+i)) //comparison takes place
{
max=*(p+i); //assigning value
}
}
printf("max value=%d",max); //display of maximum value
return 0;
}
--------------------------------------------------------------------------------------------------------
using turbo c++
-------------------------------------------------------------------------------------------------------
//program to pick the greatest number using pointer
#include <stdio.h> //header file
#include<conio.h>
int main()
{
int a[100]; //array declaration
int i,max;
int total; //variables declaration
int *p; //pointer declaration
printf("enter value of total\n");
scanf("%d",&total); //input of total value of array
printf("enter elements of array\n");
p=a; //storing of base address to pointer
for(i=0;i<total;i++) //execution of loop
{
printf("enter value for location=%d\t",i);
scanf("%d",p+i); //input of element using pointer. here array's base address is used for input
//It gets input using address starting from base location 0.
//It goes on increasing (address) as the loop moves ahead.
}
max=*(p+0); //It stores value stored in location 0
for(i=0;i<total;i++)
{
if(max<*(p+i)) //comparison takes place
{
max=*(p+i); //assigning value
}
}
printf("max value=%d",max); //display of maximum value
getch();
return 0;
}