The C language has a shape array A with 10 elements that require all the elements in the output array

Source: Internet
Author: User

<span style= "font-family:arial, Helvetica, Sans-serif; Background-color:rgb (255, 255, 255); " > has a shape array A with 10 elements that require all elements in the output array </span>

Thinking: There are 3 ways to refer to the values of each element in the array: 1. Subscript method, such as a[3];2. Computes the address of an array element by array name, and finds the value of the element

3. Use the pointer variable to point to the array element.

Use pointer variable to point to array element # include <stdio.h>int main () {    int a[10];    int i;    int *p;    printf ("Please enter 10 integers \ n");    for (i=0;i<10;i++)        scanf ("%d", &a[i]);        For (p=a;p< (a+10);p + +)            printf ("%2d", *p);        printf ("%\n");    return 0;} Computes the array element address by array name # include <stdio.h>int main () {    int a[10];    int i;    printf ("Please enter 10 integers \ n");    for (i=0;i<10;i++)        scanf ("%d", &a[i]);        for (i=0;i<10;i++)            printf ("%2d", * (A+i));        printf ("%\n");    return 0;} Subscript method # include <stdio.h>int main () {    int a[10];    int i;    printf ("Please enter 10 integers \ n");    for (i=0;i<10;i++)        scanf ("%d", &a[i]);        for (i=0;i<10;i++)            printf ("%2d", A[i]);        printf ("%\n");    return 0;}

The C language has a shape array A with 10 elements that require all the elements in the output array

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.