Assign string to character array c essay

#include<stdio.h>

#include<string.h>

intfactorial(int);

 

intmain()

{

    inti,found=0,n;

 

    charmaster_list[5][20]={

                                  "admin",

                                  "tom",

                                  "bob",

                                  "tim",

                                  "jim"

                              },name[10];

 

    printf("Enter username: ");

    gets(name);

 

    for(i=0;i<5;i++)

    {

        if(strcmp(name,master_list[i])==0)

        {

            found=1;

            break;

        }

    }

 

    if(found==1)

    {

        printf("\nWelcome %s !\n",name);

        printf("\nEnter an important multitude to help evaluate typically the factorial: ");

        scanf("%d",&n);

        printf("Factorial in %d is usually %d",n,factorial(n));

    }

 

    else

    {

        printf("Error: You can be not necessarily able to help operated this kind of program.",name);

    }

 

    // value in order to using system course produced fine

    return0;

}

 

intfactorial(intn)

{

    if(n==0)

    {

        return1;

    }

 

    else

    {

        returnn*factorial(n-1);

    }

}

  

Related essays