Jump to content

C program could not be executed at Windows command prompt

Featured Replies

 I have downloaded and installed ' C c-programs application from Windows store. I copied one program named 'Days Convertion' from it to my Notepad++  and saved it as c source file in the Documents folder. When I tried to compile it using gcc, gcc said unable to find the file. How can I fix this error?

The c program is as follows:

/*    Write a c program to convert given number of days to a measure of time


  *    given in years, weeks and days. For example 375 days is equal to 1 year


  *    1 week and 3 days (ignore leap year)


  */




 #include stdio.h


 #define DAYSINWEEK 7




 void main()


 {


    int ndays, year, week, days;




    printf("Enter the number of days\n");


    scanf("%d",&ndays);




    year = ndays/365;


    week = (ndays % 365)/DAYSINWEEK;


    days = (ndays%365) % DAYSINWEEK;




    printf ("%d is equivalent to %d years, %d weeks and %d days\n",


           ndays, year, week, days);


 }




 /*-----------------------------------------------

When I tried to compile it using gcc at windows command prompt, I got the following error several times. After giving this command at command prompt, 'DaysConvertion.c' file disappeared from the Documents folder. 

image.png.556ceae5e9e1d6c1ed32221ff693dca8.png

How can I fix this error?  

Edited by Dhamnekar Win,odd
Corrected spelling mistakes

  • Dhamnekar Win,odd changed the title to C program could not be executed at Windows command prompt

  

19 hours ago, Dhamnekar Win,odd said:

I got the correct answer.

This program is incorrect. It does not take into account leap years..

Edited by Sensei

  • Author
5 hours ago, Sensei said:

  

This program is incorrect. It does not take into account leap years..

Yes. From that point of view, this program is wrong. But we already decided to ignore the leap year and we mentioned that as  the comment.

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.