1: #include<stdio.h>
2: #include<conio.h>
3: void readdata(int *size,float *x);
4: void main()
5: {
6: int size;
7: int i;
8: float x[50];
9: readdata(&size,x); //for X[i] instead of &x[0] one can take x as address of array
10: printf("\nThe array is ");
11: for(i=0;i<size;i++)
12: printf("%.2f ",x[i]);
13: getch();
14: }
15: void readdata(int *size,float *x)
16: {
17: int i;
18: float n;
19: char ch;
20: printf("\nEnter the elements of array:\n");
21: i=0;
22: do
23: {
24: scanf("%f%c",&n,&ch);
25: *(x+i)=n;
26: i++;
27: }while(ch!='\n');
28: *size=i;
29: }
No comments:
Post a Comment