Search



Tuesday, 17 February 2015

Numbers

In this program, basically, there is  conversion of numerals to their respective alphabets. We won't need any character for this, there will be a simple execution of the program, there will be numbers as input i.e "int n;" is required and out put will be set by "switch(n)". Break statement is used because if case is found then it should come out of the scope of switch case but if it is not applied then switch case will check all the cases even if it has found the case.

Program to print number in words.

#include<stdio.h>
#include<conio.h>
void main()
{ int n;
clrscr();
printf("\n to print no. in words from 1 to 10 ");
printf("\n\n enter any no. (1 to 10) : ");
scanf("%d",&n);
printf("\n\n");
switch(n)
{ case 1 : printf("one");break;
case 2 : printf("two");break;
case 3 : printf("three");break;
case 4 : printf("four");break;
case 5 : printf("five");break;
case 6 : printf("six");break;
case 7 : printf("seven");break;
case 8 : printf("eight");break;
case 9 : printf("nine");break;
case 10 : printf("ten");break;
default : printf("invalid choice");
}
getch();
}


No comments:

Post a Comment

Guys if you think something is wrong or should be edit than please do comment.