Wednesday, 18 April 2018

Program In C To Print Month Name According To The Enter Number Ex. 1= Jan , 12 =dec


/*program to print month name*/
#include <stdio.h>
void main ()
int a ;
clrscr () ;
printf ("/n enter a number:") ;
scanf ("%d", & a) ;
switch (a)
{
case 1 ;
printf ("/n jan :") ;
break ;
case 2 ;
printf ("/n feb :") ;
break ;
case 3 ;
printf ("/n march :") ;
break ;
case 4 ;
printf ("/n april :") ;
break ;
case 5 ;
printf ("/n may :") ;
break ;
case 6 ;
printf ("/n june :") ;
break ;
case 7 ;
printf ("/n july :") ;
break ;
case 8 ;
printf ("/n august :") ;
break ;
case 9 ;
printf ( "/n sept :") ;
break ;
case 10 ;
printf ("/n oct :") ;
break ;
case 11 ;
printf ("/n nove :") ;
break ;
case 12 ;
printf ("/n dec :") ;
break ;
default :
printf ("/n invalid number :") ;
}
getch () ;
}

Here we write the program to print month name according to the enter digit with the help of the switch conditional statement . Syntax of switch conditional statement is given in previous blog so there and  read them for better understanding. click on the given link for syntax.
http://www.programmingponds.com/2018/04/program-to-input-character-from-user.html

No comments:

Post a Comment

Featured post

Program to find Volume of given box in java

class volume { public static void main (String args []) { int l=5,b=6,h=10; int volume; volume=l*b*h; System.out.println (" vol...