C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 20th, 2014, 09:23 AM
dipashapanwar dipashapanwar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2014
Posts: 1 dipashapanwar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 34 sec
Reputation Power: 0
Syntax errors - Find error in the code

can u please find error in the program?????

#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,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;1<=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;
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Syntax errors - Find error in the code


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap