Friday 10 November 2017

C Program to Print the Alternate Elements in an Array


Code:

#include

void main()
{
    int array[10];
    int i, j, temp;
    printf("enter the element of an array \n");
    for (i = 0; i < 10; i++)
        scanf("%d", &array[i]);
    printf("Alternate elements of a given array \n");
    for (i = 0; i < 10; i += 2)
        printf( "%d\n", array[i]) ;
}

Output:

enter the element of an array
12
23
45
57
68
73
84
97
120
125
Alternate elements of a given array
12
45
68
84
120

More C Programs:











100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...