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 |
What are the 4 data types?
Can you subtract pointers from each other? Why would you?
What is difference between structure and union in c?
What is static memory allocation? Explain
#define DCHAR char* typedef char* TCHAR; if using these following variables will be declared like DCHAR ch1, ch2; TCHAR ch3, ch4; then what will be types of ch1, ch2, ch3 and ch4?
What is alloca() and why is its use discouraged?
What math functions are available for integers? For floating point?
1. Write a program to reverse every second word in a given sentence.
Which is the memory area not included in C program? give the reason
If an old women's age is the same as her three grand daughters i,mean the number of days old child=the no of weeks old child=no of months old child .The total yrs of all these ppl is 114 yrs...then how old is the old woman? the yr has 365 days..and 30 days each month.
What's a good way to check for "close enough" floating-point equality?
what does the following function print? func(int i) { if(i%2)return 0; eale return 1; } main() { int =3; i=func(i); i=func(i); printf("%d",i);}