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.

A 4 digit pin using pass by reference i n c

0 votes
asked Mar 8, 2019 by Kyle (200 points)
  1. Has to be used using pass by reference 
  2. Need to get the user to enter a 4 digit pin
  3. Must be passed to another function
  4. Then passed back from the function in an array
  5. Can't enter a number greater than 9
  6. Error check in case of a character being entered 

1 Answer

0 votes
answered Apr 2, 2019 by sriteja (180 points)
char *input(char *p) //collecting array with char pointer
   input: scanf("%s",p);//reading input
    if(check(p)) //checking if any alphabets are present in the password
        printf("enter only digits\n");
        goto input;
    return p;
int check(char *p)
        return 1;
    return 0;
int main()
    char password[5],*ptr=NULL;
    printf("enter the 4 digit password\n");
    printf("entered password is %s\n",ptr);
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.