/*Exercise 1 Write a C code that will ask the user to enter 10 integer numbers and store them in an array; Then print contents of array on the screen. • Use a loop to read the numbers from the user and store them in the array. • Use another loop to print the contents of array on the screen.*/ //first step: //if you want to know (index) and clearly use this -------------><---------------- #include <stdio.h> #include <stdlib.h> int main() { int arr[10]; for(int i=0;i<=9;i++) { printf("please enter an element %d: ",i+1); scanf("%d",&arr[i]); } for(int i=0;i<=9;i++) { printf("element %d(index %d): %d\n",i+1,i,arr[i]); } return 0; } //second step: //easy and same early code: nt main() { int arr[10]; for(int i=0;i<=9;i++) { printf("please enter an element %d: ",i+1); scanf("%d",&arr[i]); } for(int i=0;i<=9;i++) { printf("%d",arr[i]); printf("\n"); } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter