jituTechnology

jituTechnology

A program to pass a pointer to array as an argument to a function and print the content of an array.

A program to pass a pointer to array as an argument to a function and print the content of an array.

Codes
/*A program to pass a pointer to array as an argument to a function and print the content of an array*/
/*Programed by          Jitendra Kr Yadav
                        10116
                        2Apr,2011*/
#include<stdio.h>
#include<conio.h>
void display(int* ,int );
void main()
{
int a[10],i,n,*ptr;
ptr=&a[0];
printf(“Enter the no of input to be taken:”);
scanf(“%d”,&n);
printf(“\n\nEnter the values:\n”);
for(i=0;i<n;i++)
{
scanf(“%d”,&a[i]);
}
printf (“\n\nThe entered values for array is:\n\n “);
display(ptr,n);
getch();
}
void display(int *p,int n)
{
for(int i=0;i<n;i++)
printf(“%d\t”,*(p+i));
printf(“Press any key to continue…”);
}
Output
Enter the no of input to be taken: 5
Enter the values:
5
2
6
7
9
The entered values for array is:
5          2          6          7          9

Press any key to continue…

No comments yet.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

August 2019
S M T W T F S
« Jun    
 123
45678910
11121314151617
18192021222324
25262728293031