write a program to print calender using for loop.




write a program to print calender using for loop. ..

Answer / abdul rahman

// Callender for 2011
#include<stdio.h>

#include<string.h>
char* month(int);
main()
{

int mm,d,m,st,start=6,count,day=0;
for(m=1;m<=12;m++)
{printf("\n");
puts(month(m));
printf("\n");
printf("su\tmo\ttu\twe\tth\tfr\tsa\n");
for(st=start;st>0;st--)
{

printf("\t");
day++;
}

if(m<8)
{

if(m%2)
count=31;
else
{count=30;
if(m==2)
count=28; }
}
else
{
if(m%2)
count=30;
else
count=31;
}
for(d=1;d<=count;d++)
{
if(start==7)
{start=0;
printf("\n");
}

printf("%d\t",d);
start++;
}
printf("\n");
}

}
char* month(int a)
{
switch (a)
{
case 1:return("Jan");

case 2:return("Feb");

case 3:return("Mar");

case 4:return("Apr");

case 5:return("May");

case 6:return("Jun");

case 7:return("Jul");

case 8:return("Aug");

case 9:return("Sep");

case 10:return("Oct");

case 11:return("Nov");

case 12:return("Dec");

default: return(0);
}

}

Is This Answer Correct ?    9 Yes 0 No

Post New Answer

More C Interview Questions

Is anything faster than c?

0 Answers  


what is difference between #include<stdio.h> and #include"stdio.h"

4 Answers  


Study the Following Points: a.One Cannot Take the address of a Bit Field b.bit fields cannot be arrayed c.Bit-Fields are machine Dependant d.Bit-fields cannot be declared as static 1. Which of the Following Statements are true w.r.t Bit- Fields A)a,b&c B)Only a & b C)Only c D)All

3 Answers   Accenture,


How can I read data from data files with particular formats?

0 Answers  


What are the basic data types associated with c?

0 Answers  






Write programs for String Reversal & Palindrome check

0 Answers   TISL,


Why c is faster than c++?

0 Answers  


What is the role of && operator in a program code?

0 Answers  


write a function to swap an array a[5] elements like a[0] as a[5],a[1] as a[4],....a[5] as a[0].without using more than one loop and use one array not to use temp array?

1 Answers   Zensar,


write a program that will read the temperature in Celsius and convert that into Fahrenheit.

1 Answers  


What is the correct declaration of main?

0 Answers  


`write a program to display the recomended action depends on a color of trafic light using nested if statments

0 Answers  


Categories