//Program to implement pointer to function
#include<stdio.h>
#include<conio.h>
void copy(int arr[],int b)
{
int i;
for(i=0;i<b;i++)
{
if(i%2==0)
arr[i]=0;
}
}
void main()
{
int j,a[10],n;
void(*ptr)(int[],int);
clrscr();
ptr=©
printf("Enter the size of an array:");
scanf("%d",&n);
printf("\n\nEnter %d elements into array:",n);
for(j=0;j<n;j++)
{
scanf("%d",&a[j]);
}
printf("\n\nEntered array: ");
for(j=0;j<n;j++)
{
printf("%d\t",a[j]);
}
ptr(a,n);
printf("\n\nUpdated array: ");
for(j=0;j<n;j++)
{
printf("%d\t",a[j]);
}
getch();
}
/*Output of Program
Enter the size of an array:5
Enter 5 elements into array:12 23 34 45 67
Entered array: 12 23 34 45 67
Updated array: 0 23 0 45 0 */
#include<stdio.h>
#include<conio.h>
void copy(int arr[],int b)
{
int i;
for(i=0;i<b;i++)
{
if(i%2==0)
arr[i]=0;
}
}
void main()
{
int j,a[10],n;
void(*ptr)(int[],int);
clrscr();
ptr=©
printf("Enter the size of an array:");
scanf("%d",&n);
printf("\n\nEnter %d elements into array:",n);
for(j=0;j<n;j++)
{
scanf("%d",&a[j]);
}
printf("\n\nEntered array: ");
for(j=0;j<n;j++)
{
printf("%d\t",a[j]);
}
ptr(a,n);
printf("\n\nUpdated array: ");
for(j=0;j<n;j++)
{
printf("%d\t",a[j]);
}
getch();
}
/*Output of Program
Enter the size of an array:5
Enter 5 elements into array:12 23 34 45 67
Entered array: 12 23 34 45 67
Updated array: 0 23 0 45 0 */
Pankaj Gaikar is a
professional blogger
from Pune, India who writes on Technology, Android,
Gadgets, social media and latest tech updates at
Punk Tech
,
Being Android
&
Shake The Tech
. Email me
HERE
0 comments :
Post a Comment