execise1
Mon Dec 12 2022 16:47:56 GMT+0000 (Coordinated Universal Time)
Saved by
@Mohamedshariif
/*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;
}
content_copyCOPY
Comments