WAP to create an array with 10 size and of int holding ability. Store values 1-10 in it. Using the length variable, access each element of the array and print it to the console. Create the array in 2 ways - one using the new operator and then storing the values individually, two by creating the array with the values directly in the array. Loop over the array using an index variable and the enhanced for as well.
Answers
Answered by
1
solution : WAP to create an array with 10 size and of int holding ability.
Store values 1-10 in it. Using the length variable, access each element
of the array and print it to the console
#include <stdio.h>
#include <conio.h>
void main()
{
int arr[10] ={1,2,3,4,5,6,7,8,9,10};
int len=10 , i;
for ( i = 0 ; i < len ; i ++ )
{
printf ("%d \t ",arr[i])
}
getch();
}
#include <stdio.h>
#include <conio.h>
void main()
{
int arr[10] ={1,2,3,4,5,6,7,8,9,10};
int len=10 , i;
for ( i = 0 ; i < len ; i ++ )
{
printf ("%d \t ",arr[i])
}
getch();
}
Similar questions
History,
7 months ago
English,
7 months ago
English,
7 months ago
Chemistry,
1 year ago
Computer Science,
1 year ago