Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

In c language, how to print one particular element of an array?

0 votes
asked May 21, 2019 by anonymous
I want to print an array, for example a[5]={3,6,-9,0,4} and then to print only the second element (number 6).

3 Answers

0 votes
answered May 21, 2019 by Guillermo (180 points)
int a[5]={3,6,-9,0,4};

    printf("%d",a[1]);
0 votes
answered May 21, 2019 by Divya Sree (140 points)
#include<stdio.h>

int main()

{

int a[5]={3,6,-9,0,4}

printf("%d",a[1]);

}
0 votes
answered Jun 22, 2019 by Robert Parry (240 points)
or:

#include<stdio.h>

int main()

{

    int a[5] = {3, 6, -9, 0, 4};

    printf("%d", (int)*(a + 1));

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...