#include <stdio.h>
#include <stdlib.h>
struct student
{
    char name[30];
    char dob[30];
    int rollno;
    float percent;
    int sub[3];
    int total;
};
int main(void)
{
    int i, n,a,c,*ptr;
    char ch;
    struct student *st;
    
    printf("Enter number of students data you want to enter:\n");
    scanf("%d",&n);
    st=(struct student*) malloc(n * sizeof(struct student));
    if(st == NULL) 
    {
        printf("Error! memory not allocated.");
        exit(0);
    }
    for(i=1;i <= n;i++)
    {
        printf("Enter name of student %d\n",(i));
        scanf("%s",&(st+i)->name);
        printf("Enter Roll No of student %d\n",(i));
        scanf("%d",&(st+i)->rollno);
        printf("Enter Date Of Birth of student %d\n",(i));
        scanf("%s",&(st+i)->dob);
        printf("Enter marks for 3 subjects of student %d\n",(i));
        scanf("%d %d %d",&(st+i)->sub[0],&(st+i)->sub[1],&(st+i)->sub[2]);
        (st+i)->total = ((st+i)->sub[0]+(st+i)->sub[1]+(st+i)->sub[2]);
        printf("Total Marks of student %d = %d\n\n",(i), (st+i)->total);
    }
    printf("\n");
    printf("\n<1>To display details of students\n");
    printf("\n<2>exit\n");
    printf("Enter your choice:\n");
    scanf("%c",&ch);
    switch(ch)
    {
    case '1':
    {      
        for(i=1; i <= n;i++)
        { 
            printf("\n%d.%s",(st+i)->rollno,(st+i)->name);
        }
        printf("\n Enter Roll no to display info of student");
        scanf("%d",&a);
        {
            c=a;
            a=i;
            i=c;
        if((st+i)->sub[0]<33||(st+i)->sub[1]<33||(st+i)->sub[2]<33)
        {   
            printf("\nName of student: %s",(st+i)->name);
            printf("\nRoll No of student: %d",(st+i)->rollno);
            printf("\nDate of Birth : %s",(st+i)->dob);
            printf("\nTotal of student: %d",(st+i)->total);
            printf("\nStudent Status fail");
            return 0;
        }
        printf("\nName of student: %s",(st+i)->name);
        printf("\nRoll No of student: %d",(st+i)->rollno);
        printf("\nDate of Birth : %s",(st+i)->dob);
        printf("\nTotal of student: %d",(st+i)->total);
        (st+i)->percent=((st+i)->total)/3;
        printf("\nPercent of Student = %f",(st+i)->percent);
        if((st+i)->percent>=33)
        {
            printf("\nStudent status:- PASS\n");
        }
        else
            printf("\nStudent status:-FAIL\n");
        if((st+i)->percent>=90)
            printf("Grade= A1\n");
        else if (80<=(st+i)->percent)
            printf("Grade= A2\n");
        else if(70<=(st+i)->percent)
            printf("Grade= B1\n");
        else if(60<=(st+i)->percent)
            printf("Grade= B2\n");
        else if(50<=(st+i)->percent)
            printf("Grade= C1\n");
        else if(40<=(st+i)->percent)
            printf("Grade= C2\n");
        else if(33<=(st+i)->percent)
            printf("Grade= D\n");
        else if((st+i)->percent<33)
            printf("Grade= F\n");
        }
        break;
    }
    case '2':
    {
        return 0;
    }
    default:
        printf("Invalid! Try again...\n");
    }
    free(st);
    return 0;
}
I want my program to take input of various details of students and display them when I enter the roll no. of student. However, the switch statement is not executing; the program just exits after taking input. I checked syntax, but it's correct I don't know what the issue is. If I could get a hint about the issue it would be great.
 
     
     
    