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

March 2024
S M T W T F S
 12
3456789
10111213141516
17181920212223
24252627282930
31