can any one make this program run.. in proper output?

This is a discussion on can any one make this program run.. in proper output? within the C++ Programming forums, part of the General Programming Boards category; Code: PHP Code: [ PHP ][ PHP ]  [/PHP][/PHP] #include<iostream.h> #include<conio.h> int step1 (int); void month_name(int); int no_days(int,int); int leap(int); ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    6

    can any one make this program run.. in proper output?

    Code:
    PHP Code:
    [PHP][PHP
    [/PHP][/PHP]
    #include<iostream.h>
    #include<conio.h>

    int step1 (int);
    void month_name(int);
    int no_days(int,int);
    int leap(int);

    void main()
    {
    restart:
    clrscr();
    cout<<"Enter year : ";
    unsigned int y,m;
    cin>>y;
    int x;
    x=step1(y);
    int month[14][12]= {1,4,4,7,2,5,7,3,6,1,4,6,
    2,5,5,1,3,6,1,4,7,2,5,7,
    3,6,6,2,4,7,2,5,1,3,6,1,
    4,7,7,3,5,1,3,6,2,4,7,2,
    5,1,1,4,6,2,4,7,3,5,1,3,
    6,2,2,5,7,3,5,1,4,6,2,4,
    7,3,3,6,1,4,6,2,5,7,3,5,
    1,4,5,1,3,6,1,4,7,2,5,7,
    2,5,6,2,4,7,2,5,1,3,6,1,
    3,6,7,3,5,1,3,6,2,4,7,2,
    4,7,1,4,6,2,4,7,3,5,1,3,
    5,1,2,5,7,3,5,1,4,6,2,4,
    6,2,3,6,1,4,6,2,5,7,3,5,
    7,3,4,7,2,5,7,3,6,1,4,6};
    cout<<"Enter month (1 - 12) : ";
    month_input:
    cin>>m;
    if(m<1 || m>12)
    {
    cout<<"Enter a valid month (1 - 12) : ";
    goto month_input;
    }
    cout<<"

    ";
    month_name(m);
    cout<<' '<<y<<"

    Mon Tue Wed Thu Fri Sat Sun
    ";
    int j=month[x-1][m-1], days=no_days(m,y);
    for (int i=0; i<j-1; i++)
    cout<<' ';
    for(i=1; i<=days; i++)
    {
    cout<<i<<' ';
    if(j==7)
    {
    cout<<'
    ';
    j=1;
    }
    else
    j++;
    }
    cout<<"

    Try for another month? (y/n) : ";
    char ch;
    cin>>ch;
    if(ch=='y' || ch=='Y')
    goto restart;
    }
    int step1 (int y)
    {
    int x=y%7;
    x+=(y-1)/4;
    x-=(y-1)/100;
    x+=(y-1)/400;
    x=x%7;
    if(x==0)
    x=7;
    if(leap(y))
    x+=7;
    return x;
    }
    void month_name(int m)
    {
    switch(m)
    {
    case 1 : cout<<"January";
    break;
    case 2 : cout<<"February";
    break;
    case 3 : cout<<"March";
    break;
    case 4 : cout<<"April";
    break;
    case 5 : cout<<"May";
    break;
    case 6 : cout<<"June";
    break;
    case 7 : cout<<"July";
    break;
    case 8 : cout<<"August";
    break;
    case 9 : cout<<"September";
    break;
    case 10: cout<<"October";
    break;
    case 11: cout<<"November";
    break;
    case 12: cout<<"December";
    break;
    }
    }

    int no_days(int mon, int y)
    {
    int d;
    switch(mon)
    {
    case 1 :
    case 3 :
    case 5 :
    case 7 :
    case 8 :
    case 10:
    case 12: d=31;
    break;
    case 4 :
    case 6 :
    case 9 :
    case 11: d=30;
    break;
    case 2 : if(leap(y))
    d=29;
    else
    d=28;
    break;
    }
    return d;
    }
    int leap (int y)
    {
    if (y%100==0)
    if (y%400==0)
    return 1;
    else
    return 0;
    else
    if (y%4==0)
    return 1;
    else
    return 0;
    }
    PHP Code:
    [PHP
    [/PHP]

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,438
    nobody wants to read it until its formatted with code tags and indented, and what is the proper output supposed to be? we cannot guess

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    your compiler is outdated
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    82
    That is the most screwed up post I have ever seen here. Were you on drugs when you created this thread? Why the hell are there random boxes and weird php tags everywhere? What is going on?!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Writing a program to make a calendar
    By Northstar in forum C Programming
    Replies: 17
    Last Post: 11-07-2007, 10:34 AM
  2. Make a program run at startup
    By cookie in forum Tech Board
    Replies: 2
    Last Post: 06-08-2007, 08:36 PM
  3. how to make my program run on windows start up
    By kantze in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 03-24-2007, 11:14 AM
  4. DEV-C++ made program crashes when run from outside the ide
    By rainmanddw in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2006, 09:27 PM
  5. Replies: 5
    Last Post: 04-17-2003, 07:07 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21