write a program to print calender using for loop.
Answer Posted / 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 View All Answers
Between macros and functions,which is better to use and why?
How can you call a function, given its name as a string?
What is the right type to use for boolean values in c?
please give me some tips for the placement in the TCS.
Why main function is special give two reasons?
What are identifiers in c?
Tell us something about keyword 'auto'.
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.
What the advantages of using Unions?
Do array subscripts always start with zero?
How can you avoid including a header more than once?
code for replace tabs with equivalent number of blanks
Is there a way to compare two structure variables?
What are the advantage of c language?
Write a program to maintain student’s record. Record should
not be available to any unauthorized user. There are three
(3) categories of users. Each user has its own type. It
depends upon user’s type that which kind of operations user
can perform. Their types and options are mentioned below:
1. Admin
(Search Record [by Reg. No or Name], View All Records,
Insert New Record, Modify Existing Record)
2. Super Admin
(Search Record [by Reg. No or Name], View All Records,
Insert New Record, Modify Existing Record, Delete Single Record)
3. Guest
(Search Record [by Reg. No or Name], View All Records)
When first time program runs, it asks to create accounts.
Each user type has only 1 account (which means that there
can be maximum 3 accounts). In account creation, following
options are required:
Login Name: <6-10 alphabets long, should be unique>
Password: <6-10 alphabets long, should not display
characters when user type>
Confirm Password: