Proxy > Gmail Facebook Yahoo!

Write a c program that accepts a month and day




#include
#include
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;
}



Responses

0 Respones to "Write a c program that accepts a month and day"


Send mail to your Friends.  

Expert Feed

 
Return to top of page Copyright © 2011 | My Code Logic Designed by Suneel Kumar