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

GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)

0 Answers  


write a program for 7*8 = 56 ? without using * multiply operator ? output = 56

6 Answers   Xavient,


what are the advantage and disadvantage of recursion

5 Answers  


explain how do you use macro?

0 Answers  


What is the difference between functions abs() and fabs()?

0 Answers  






#define d 10+10 main() { printf("%d",d*d); }

6 Answers  


A set of N billiard balls are set on a one-dimensional table. The table is 1 meter long, set north-south with two pockets at either side. Each ball has zero width and there is no friction so it is moving with a fixed velocity of either northward or southward and bounces back in a perfect elastic collision from other balls it encounter on its way (or drop into one of the pockets). Your job is to keep track of the balls movements. Task Please write a program that gets the initial place, speed and direction of all the balls and gives the position of a specific ball after t seconds. Input The first line contains the number of scenarios. Each one of the other lines in the input contains a scenario: The first number, N, is the number of balls; followed by N pairs of numbers: the distance in centimeters from the south end of the table and the speed (positive speed meaning it moves northward); the last two numbers are the number i of the target ball you should track and the time T in seconds. Output The output is a single number for each line which is the place (distance in centimeters from the south end of the table) of the tracked ball after T seconds. Note: There is no new line character at the end of the result. Sample Input 5 1 50 1 1 1000 1 50 1 1 6 1 60 -2 1 6 2 10 1 95 -1 2 30 2 10 1 95 -1 2 60 Sample Output 100 56 48 65 70

0 Answers  


do u print this format '(((())))'. This brackets is based on user input like 4 or 5 or 6,without using any loop's?

1 Answers   Oracle,


c program to arrange digits in a no in ascending and descending order

1 Answers  


Write a program that can show the multiplication table.

0 Answers   Student,


hi , please send me NIC written test papers to sbabavalli@gmail.com

0 Answers   NIC,


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

1 Answers   TCS,


Categories