/*This program is going infinite.PLS help*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f,flag=0;
printf("Enter first date");
scanf("%d%d%d",&a,&b,&c);
printf("Enter second date");
scanf("%d%d%d",&d,&e,&f);
const int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
while(c!=f||b!=e||a!=d)
{
a++;
if((b==4)||(b==6)||(b==9)||(b==11))
f=30;
else if(b==2)
{
if(d%4==0)
f=29;
else
f=28;
}
else
f=31;
if(a>f)
{
b++;
a=1;
}
if(b==13)
{
c++;
b=1;
}
flag++;
}
printf("%d",flag);
getch();
}
BHUJI
0
Newbie Poster
Recommended Answers
Jump to PostFirst of all: please use codetags. It makes your code easier to read:
#include<stdio.h> int main() { int a,b,c,d,e,f,flag=0; printf("Enter first date"); scanf("%d%d%d",&a,&b,&c); printf("Enter second date"); scanf("%d%d%d",&d,&e,&f); const int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; while(c!=f||b!=e||a!=d) { a++; if((b==4)||(b==6)||(b==9)||(b==11)) f=30; else if(b==2) { if(d%4==0) f=29; else f=28; } else f=31; if(a>f) { …
Jump to PostWhat is this code supposed to do?
Still don't know
All 7 Replies
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
BHUJI
0
Newbie Poster
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
carljonson07
0
Newbie Poster
ramagiripratap
0
Newbie Poster
anand01
0
Junior Poster
Sby_1
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.