Write a c program that accepts a month and day









#include<stdio.h>
#include<stdlib.h>
int main(){
    char monthDate[15];
    int i=0;
                                    
    //accepting month and date from user
    printf("Enter the month and date : ");
    gets(monthDate);
   
    //getting the array index of blank space
    while(monthDate[++i]!=' ');
   
    //replacing the blank space to null character
    monthDate[i]='\0';
   
    //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;
}








Post a Comment