How to scan an array and how to print it on screen.
BM Balmiki Mandal 27 Dec 2022 16 views 0 comments C Programming

How to scan an array and how to print it on screen.

How to Scan and Print an Array in C Programming Language

To scan an array and print it on the screen in C language, you can use a for loop to iterate over the array elements and scanf to read the input values from the user, and printf to display the output values on the screen. Here's an example program that shows how to do this:

input:

 10   20   30   40   50 

output:

 10   20   30   40   50 

 

How to Scan and Print an Array | Example Code

#include
void main()
{
    int a[5],ele,i;
    ele=sizeof(a)/sizeof(a[0]);
    printf("enter the lelements of an array:\n");
    for(i=0;i<ele;i++)//for scanning
    scanf("%d",&a[i]);

    printf("array elelments are:\n");
    for(i=0;i<ele;i++)//for printing
    printf(" %d",a[i]);
    printf("\n");
}

In this program, we first declare an integer array of size 5. Then, we use a for loop to scan the array elements from the user input using the scanf function. Next, we use another for loop to print the array elements on the screen using the printf function.

When the program runs, it prompts the user to enter 5 integers. After the user enters the values, the program prints the array elements on the screen.

Here's an example of how the program output might look like:

Enter 5 integers: 10 20 30 40 50
The array elements are: 10 20 30 40 50

Note that you can adjust the size of the array and the number of elements you scan and print by changing the loop conditions in the program.

Further Reading:

what is an array

how to declare and initialization an array

Dynamic Declaration of an array

How to scan an array and how to print it on screen.

Enroll Now:

[ C-Programming From Scratch to Advanced 2023-2024] "Start Supercharging Your Productivity!"

Contact Us:

  • For any inquiries, please email us at [info@electro4u.net].
  • Follow us on insta  [ electro4u_offical_ ] for updates and tips.

Note: If you encounter any issues or specific errors when running this program, please let me know and I'll be happy to help debug them!

#what is an array # how to declare and initialization an array # Dynamic Declaration of an array # How to scan an array and how to print it on screen. # write a program to reverse printing of an array( only reverse printing not disturb the array original elements). # Write a program for reversing of an array ( original array element reverse ). # write a program to reverse half the elements of an array. # write a program to reverse adjacent elements of an array. # write a program to print prime numbers in 10 array elements. # write a program to print Armstrong numbers in 10 array elements. # write a program to print palindrome numbers in 10 array elements. # write a program to print perfect numbers in 10 array elements. # How to array are in the contiguous memory location. # how array name is treated as a constant pointer. # write a program to copy one array element to another array element. # write a program to copy one array element to another array element in reverse manner. # write a program to murgh two arrays in a single array. # write a program to print the elements of an array using an integer pointer. # write a program to print the elements of an array using a character pointer. # write a program to find the largest elements of a given array with an index. # write a program to find the smallest elements of a given array with an index. # write a program to find the first largest and first smallest elements of a given array. # write a program to find the second largest elements of a given array. # write a program to find the second smallest elements of a given array. # write a program to find the second largest and second smallest elements of a given array. # write a program to find the first largest and second-largest elements of a given array. # write a program to find the first smallest and second smallest elements of a given array. # Bubble shorting # selection shorting
Share:

0 Comments

No comments yet, Be the first to comment.

Post a Comment

Please sign in to post a comment.

Related Posts

C Bitwise Operators Explained: 10 Practice Programs with Output

E.1: Bitwise vs. Logical Operators#include<stdio.h> int main(void){ int x=7,y=19; printf("%d %d ",x&y...

AG Anvesh G 29 Nov 2026
Bit wise operators Assignment

Bitwise Operators practical assignment: Take runtime input, bit-level manipulation, and different data units r...

AG Anvesh G 27 Sep 2026
Understanding Float and Double Binary Representation in C

Understanding Float and Double Binary Representation in CIntroduction:When we store decimal numbers such as 10...

AG Anvesh G 31 May 2026