Question:

Im trying to make a progrm that will read a date(month,day, & year) in integer form. Help me edit my progrm?

by  |  earlier

0 LIKES UnLike

include<stdio.h>

void main()

{

int month, day, year;

char m;

again:

printf("Enter month:\t");

scanf("%f", &month);

printf("\nEnter day:\t");

scanf("%d", &day);

if (day==0) && (day>=32)

printf("\nInvalid! Please try again.");

goto again;

printf("Enter year:\t");

scanf("%d", &year);

switch(month)

{

case '1':

m=January;

break;

case '2':

m=February;

break;

case '3':

m=March;

break;

default:

printf("\nInvalid! Please try again.");

goto again;

}

printf("\n\n %d %d, df", month, day, year);

}

//Thats my program. There are errors. im not really familiar in C programming.. Can somebody help me?? Please.. asap..Tnx!!

 Tags:

   Report

4 ANSWERS


  1. why would you want the month to be a float type?  I see at least 3 issues in this code - first, you store the month as a float and then try to print it as int.  you probably do not want to do that.  Secondly, remember that &quot;m&quot; is a char.  your assignment of the month to a char will not work or compile. (also, strings need to be quoted). Your last printf statement only has 2 % but you are trying to print out 3 values...  Think about what will happen if a user enters -1 for the day.  Start with these issues.


  2. Try using C++, and there is a time function.

  3. Your using the wrong codes! open your computer and find circuitboard memory c-198//?cptmry/storage.@=798 and enter the code through the 3rd line 1010101010010101001010111010101010010101... This should make the program work. Also, it only works with a Sthom model circuitboard.

  4. Geeez, where to begin.

    First, you are trying scan the month as a float

    Scan it as an int

    scanf(&quot;%d&quot;, &amp;month);

    Second, m is defined as a char.  Sorry this is C, you can&#039;t assign

    m = February unless you&#039;ve enumerated all the month names elsewhere are m was an int.

    You can&#039;t even do this

    m = &quot;February&quot;

    C does not have strings like C++ or Java or C#.

    You can however do this

    char* m;

    m = &quot;February\0&quot;;

    Your printf token for year is also incorrect.

    printf(&quot;\n\n %d %d, %d&quot;, month, day, year);

Question Stats

Latest activity: earlier.
This question has 4 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.