/* Problem: This programs fills an array with a value submitted by the user. */ #include <stdio.h> /* array parameter can be expressed as a pointer */ /* *list is the same thing as list[] */ void fill_array (int *list, int n, int in_value) { int i; for (i=0; i<n; ++i) list[i] = in_value; } int main (void) { int x[100]; int i; /* &x[0] is the address of the x[0] */ /* which is the same thing as x */ fill_array (&x[0], 100, 5); /* printing the array for verification */ for (i=0; i<100; ++i) printf ("%d ", x[i]); return (0); }
Array : With Pointer
এতে সদস্যতা:
মন্তব্যগুলি পোস্ট করুন (Atom)
//This programs fills an array with a value submitted by the user.
উত্তরমুছুনinclude (stdio.h)
void filar (int *in, int n)
{
int j=0,value;
printf("Enter the value:");
scanf("%d",&value);
while(j<n)
{
in[j]=value;
j++;
}
}
int main (void)
{
int x[100];
int j=0;
filar (&x[0],100);
while(j<100)
{
printf (" %d",x[j]);
j++;
}
getch();
}
#include
উত্তরমুছুনmain()
{
int i,n;
printf("Enter your value:\n");
scanf("%d",&n);
int a[n];
printf("Enter your array value:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("your array value is:\n");
for(i=0;i<n;i++)
printf("\n%d",a[i]);
}
Zubair Hossain
উত্তরমুছুন#include
using namespace std;
int main()
{
int i,n,array[n];
cout<<"Enter your value:" <>n;
cout<<"Enter your array value:"<>array[i];
}
cout<<"your array value is:"<<endl;
for(i=0;i<n;i++)
cout<<array[i]<<endl;
}
#include
উত্তরমুছুনusing namespace std;
int main()
{
int i,array[10];
cout<<"Enter your array value:"<>array[i];
}
cout<<"your array values are:"<<endl;
for(i=0;i<10;i++)
cout<<array[i]<<endl;
}