You are on page 1of 6

SOURCE FILE

/**************************************************************************
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

REFERENCES :Capgemini training

**************************************************************************/
#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

REFERENCES :Capgemini training

***************************************************************************
***********************/
#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.

*** NAME : Sneha DR


DATE :16/11/2022
REFERENCES :Capgemini training
***************************************************************************
**************/

#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

4.exit enter your choice:

1 displaying point_value(): the value of the pointer :5 the address of


the value:0x7fffc6f65d8c dereference of the pointer:5 enter your
choice:2 displaying point_int(): value of number[0]=10 address of
number[0]=0x7fffc6f65d80 deferenced value[0]=10 value of
number[1]=20 address of number[1]=0x7fffc6f65d84 deferenced
value[1]=20 value of number[2]=30 address of
number[2]=0x7fffc6f65d88 deferenced value[2]=30 value of
number[3]=50 address of number[3]=0x7fffc6f65d8c deferenced
value[3]=50 value of number[4]=60 address of
number[4]=0x7fffc6f65d90 deferenced value[4]=60 value of
number[5]=70 address of number[5]=0x7fffc6f65d94 deferenced
value[5]=70 enter your choice:3 displaying point_char(): value of
names[0]=ram address of names[0]=0x7fffc6f65d70 deferenced
names[0]=ram value of names[1]=roy address of
names[1]=0x7fffc6f65d78 deferenced names[1]=roy value of
names[2]=rita address of names[2]=0x7fffc6f65d80 deferenced
names[2]=rita value of names[3]=sitha address of
names[3]=0x7fffc6f65d88 deferenced names[3]=sitha enter your
choice:5 invalid choiceenter your choice:4

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

!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/


!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.9~svn20110310 //
point_char pointarray.c /^void point_char()$/;" f
point_int pointarray.c /^void point_int()$/;" f
point_value pointarray.c /^void point_value()$/;" f
~

You might also like