Professional Documents
Culture Documents
/**************************************************************************
FILENAME : pointarray.c
DESCRIPTION ::This file creates source file to point the value, point the address,
dereference the point.
NAME : Sneha DR
DATE :16/11/2022
**************************************************************************/
#include<stdio.h>
#include "pointarray.h"
/**************************************************************************
* FUNCTION NAME: point_value
* ******************************************************************/
void point_value()
{
int number; int
*value=NULL ;
number=5; value
=&number;
printf("the value of the pointer :%d\t\n",*value);
printf("the address of the value:%p\t\n",&number);
printf("dereference of the pointer:%d\t\n",*&number);
}
/**************************************************************************
***********************
** FUNCTION NAME: point_int
************************************************************************
***********************/ void point_int()
{
/* int val=5;*/ int
number[6]={10,20,30,40,50,60};
int *pointer="NULL"; pointer=
&number;
for(int i=0;i<6;i++)
{
printf("value of number[%d]=%d\n",i,number[i]);
printf("address of number[%d]=%p\n",i,&number[i]);
printf("deferenced value[%d]=%d\n",i,*&number[i]);
}
}
/**************************************************************************
***********************
** FUNCTION NAME: point_char
***************************************************************************
********************/
void point_char()
{
/*int val=6;*/
char *name[]={"Sneha","Thanu","Swathi","Bharthi","Prema"};
for(int j=0;j<4;j++)
{
printf("value of names[%d]=%s\n",j,name[j]);
printf("address of names[%d]=%p\n",j,&name[j]);
printf("deferenced names[%d]=%s\n",j,*&name[j]);
}
}
HEADER FILE
/********************************ii*****************************************
************************
**** FILENAME : pointarray.h
****
**** DESCRIPTION :This file creates header for point the value, point the
address,dereference the point. ***
*** NAME :Sneha DR
DATE :16/11/2022
***************************************************************************
***********************/
#include<stdio.h>
void point_value();
void point_int();
void point_char();
MAIN FILE
/**************************************************************************
****************************** **
* FILENAME : point_main.c
****
**** DESCRIPTION ::This file is the main file.
#include "pointarray.h"
int main()
{
int choice=-1; printf("***********menu
driven****************\n"); printf("1.point
the value\n"); printf("2.array of integer
value\n"); printf("3.array of character\n");
printf("4.exit\n"); while(1)
{ printf("enter your
choice:");
scanf("%d",&choice);
if(choice==1)
{ printf("displaying point_value():\n");
point_value();
}
else if(choice==2)
{ printf("displaying point_int():\n");
point_int();
}
else if(choice==3)
{ printf("displaying point_char():\n");
point_char();
}
else if(choice==4)
{
break;
}
else
{ printf("invalid choice");
}
}
/*point_value();
point_int();
point_char();*/
return 0;
}
OUTPUT
sneha@GESLLR0ME3:~/CPROGRAM/day-1/assignment/day-4$ ./a.out
***********menu driven****************
1.point the value
2.array of integer value
3.array of character
sneha@GESLLR0ME3:~/CPROGRAM/day-1/assignment/day-4$
MAKEFILE
CC=gcc
CFLAGS= -Wall -g LIBS= -lm
all: pointarray.c
point_main.c
$(CC) $(CFLAGS) pointarray.c point_main.c -o pointarray.out gcc
-g -Wall pointarray.c point_main.c -o pointarray.out
clean: rm -rf
pointarray.out
CTAGS