#include <stdio.h>
#include <stdlib.h>
int i=-1;
 main()
{
    int a[30],n;
    printf("enter the no of terms: ");
    scanf("%d",&n);
    store(a,n);
}
int store(int a[],int y);
{
    if(i==y)
    {
        return \\it should return and terminate 
        exit(0);
    }


    i++;
    printf("enter the number: ");
    scanf("%d",&a{i]);
    store(a,y);

i know i had made a mistake but where can i make a correction please solve this.i have store array values without using for loop

is it possible to store array value like this???please solve this problem

iam just trying to store values in recursive method

hello somdebody there please solve this

#include <stdio.h>

#define MAX 5

void store(int a[], int i, int n);

int main(void)
{
    int a[MAX];
    int i;

    store(a, 0, MAX);

    /* Test the result */
    for (i = 0; i < MAX; ++i)
        printf("%d ", a[i]);
    puts("");

    return 0;
}

void store(int a[], int i, int n)
{
    if (i == n)
        return;

    do {
        fflush(stdin); /* Placeholder for a better solution */
        printf("Enter number #%d: ", i + 1);
        fflush(stdout);
    } while (scanf("%d", &a[i]) != 1);

    store(a, i + 1, n);
}

superb deceptikon thanks a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.