C program to Display 1D numbers in Array.

 

We know that An array is a sequence of data item of homogeneous value(same type).Here is a program which will ask to provide input from user and display them on screen.

 

Let’s write a program to print all numbers in  Array.

 

Step :1 Let’s  Open turbo C and write the following code.

 

// Code

 

//Add preprocessor

 

#include<stdio.h>

#include<conio.h>

void main()

{

int a[10],i;

 

// Clear screen

clrscr();

 

printf(“\n enter all numbers : ”)

for(i=0;i<=10;i++)

{

scanf(“%d”,&a[i]);

}

printf(“\n numbers are:”);

{

for(i=0;i<=10;i++)

{

 

// Print the result

printf(“\n %d”,a[i]);

}

}

getch();

}

 

 

Step 2: Save it and name it ARRAY.CPP.

 

 

Step 3: Compile the program to check errors and correct them.

 

 

Step 4: Run the program and see output.

 

 

//output

 

array

 

Happy coding.

 

 

 

 

 

 

Tags: , ,