Read OnLine C- Program Example
05_ARRAY | |
---|---|
PRAC 5 | PRAC 6 |
//wap to print element using float #include<stdio.h> #include<conio.h> void main() { float a[5],i; clrscr(); a[0]=12.5; a[1]=23.7; a[2]=45.4; a[3]=65.6; a[4]=23.7; for (i=4;i>=0;i--) { printf("%f \n",a[i]); } getch(); } -----output------ 23.7 65.6 45.4 23.7 12.5 |
//wap to print element using for loop (scanf) #include<stdio.h> #include<conio.h> void main() { int a[5],i; clrscr(); printf("Enter array element:\n"); for (i=0;i<=4;i++) { printf("\n Enter element:",i); scanf("%d",&a[i]); } for (i=0;i<=4;i++) { printf("\n Element:%d=%d",i,a[i]); } getch(); } -------output----- Enter array element: Enter element:23 Enter element:64 Enter element:45 Enter element:11 Enter element:12 Element:0=23 Element:1=64 Element:2=45 Element:3=11 Element:4=12 |
Previous | Next |
Download | Download |