Write a c program that accepts a month and day

int main(){
    char monthDate[15];
    int i=0;
    //accepting month and date from user
    printf("Enter the month and date : ");
    //getting the array index of blank space
    while(monthDate[++i]!=' ');
    //replacing the blank space to null character
    //Printing the string upto first null character i.e. month
    printf("Month : %s\n",monthDate);

    //Printing the string after the first null character i.e.       day
    printf("Day : %d",atoi(monthDate+i+1));
   //atoi: Converting string to int
    return 0;

1 comment:

Anonymous said...