Menu driven, function based C program for strings

Write a menu driven program which performs following operations on strings. Write separate function for each option,

- Check String is Substring of Another String
- Count Occurrences of Character
- Exit.


Solution:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int a;
    char str1[30],str2[30],str3[30],z;
    int i=0,c=0;
    //while(1)
    do
    {
        printf("\t\tMENU\n");
        printf("----------------------------------------------");
        printf("\n1. Check String is Substring of Another String\n");
        printf("\n2. Count Occurrences of Character \n");
        printf("\n3. Exit\n");
        printf("\nEnter Your choice: ");
        scanf("%d",&a);
        switch(a)
        {
            case 1:
                printf("\nEnter First String:");
                scanf("%s",str1);
                printf("\nEnter Second String:");
                scanf("%s",str2);
                if(strstr(str1,str2)==NULL)
                    printf("\nSecond String is Not Substring of First String\n\n");
                else
                    printf("\nSecond String is Substring of First String\n\n");
                break;
            case 2:
                printf("\nEnter String: ");
                scanf("%s",str3);
                printf("\nEnter Character : ");
                scanf("%s",&z);
                for(i=0;str3[i]!='\0';i++)
                {
                    if(z==str3[i])
                        c++;
                }
                printf("\nNumber of Occurrences of '%c' : %d\n\n",z,c);
                break;
            case 3:
                exit(0);
            default:
                printf("\nNot Valid Choice\n\n");
        }
    }while(a!=3);
    return 0;
}


Output:

string substring occurance