Number to word Conversion C Language Program

Question : Write a program which takes number as integer and convert it into string?
i.e
   Input : 123
   Output : One Hundred Twenty Three Only

Answer : 

#include <stdio.h>
#include <conio.h>
void ntoword(int);
void main()
{
int n;
clrscr();
printf("Enter number>> ");
scanf("%d",&n);
ntoword(n);
getch();
}
void ntoword(int n)
{
char *one[]={"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};
char *two[]={"Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"};
char *three[]={"","Twenty","Thirty","Fourty","Fifty","Sixty","Seventy","Eighty","Ninety"};
int ar[3],i,j;
i=n>99?2:n>9?1:0;
for(j=n;j>0;j/=10,i--)
ar[i]=j%10;
if(n>999)
printf("out of range");
else
{
if(n>99) /* for three digit*/
{
printf("%s Hundred ",one[ar[0]]);
if(ar[1]>1)
{
printf(" %s %s Only",three[ar[1]-1],one[ar[2]]);
}
else
{
printf("%s Only",two[ar[2]]);
}
}
else if(n>9) /*for two Digit */
{
if(ar[0]>1)
{
printf(" %s %s Only",three[ar[0]-1],one[ar[1]]);
}
else
{
printf(" %s Only",two[ar[1]]);
}

}
else   /*One Digit Only */
{
printf("%s only",one[ar[0]]);
}
}

}

Practical Question paper of C Language


One Dimension Practical model question paper

Q 1. Write a  program to shift array element with next one . Last element will replace with first element ?

Q 2. Write a program to count even and odd number in an array?

Q 3.Write a program to make three array name mArry, even & odd move array value in even & odd array respect to this type ?

Q 4.Write a program to find smallest and highest number from an array?

Q 5. Write a program to print an array in reverse order?

Q 6. Write a program to print only consecutive number of an array?

Q 7. Write a program to implement union and intersection?

Q 8. Write a program to merge two array into a single array?

Q 9.Write a program to spilt an array into two equal parts ?

Q 10. Write a program to input Fibonacci into array?

Q 11.Write a program to find out prime number between given range and saved these number into array. Range should be up-to 1 to 10000 ?

Q 12.Write a program to input 10 numbers and print each element with multiply by its equivalent index position?

Q 13. Write a program to print an array value without using loop ?

Q 14.Write a program search a number in array ?

Q 15.Write a program to print an array value skip by one index?

Q 17. Write a program to input ASCII value and print its equivalent character.Using 7 bit ASCII/

One Dimension Character Array  Programs

1. Write a program to count Vowels and consonant?

2. Write a program to count no. of word in an array?

3. Write a program to convert lower case character into upper case

4. Write a program to print only consecutive appeared character

5. Write a program to implement concatenation?

6.  Write a program to implement substring function type functionality

7. Write a program to input small letter if capital letter is there ignore that

8. Write a program accept any case input and convert it small case

9. Write a program input character only and display error message on any other input?

10. Write a program to search a substring and print its index

11. Write a program to search a word and reverse that

12. Write a program implement encryption i.e. change each character to two character forward. i.e.   A-> C,B->E

13. Write a program to implement following format
              G                                              GIRFA
              GI                                             GIRF
              GIR                                          GIR
              GIRF                                        GI
              GIRFA                                     G

14. Write a program to implement abbreviation i.e.
Input : Ashok Kumar Yadav
Output : A.K. Yadav

15. Write a program to implement find and replace all functionality

16. Write a program to check whether a string is palindrome or  not

17. Write a program reverse a string

18. Write a program to reverse each word into array

19. Write a program to input string password. i.e.(A Small and Capital character , A number and a special symbol)

20. Write a program to check validity of an email address. (an email can have only one @ symbol after that . is required and no space is allowed)

21. Write a program count frequency of each character individually.
22. Write a program to convert number to word?
   i.e.    123
            One Hundred Three Only

No comments:

Post a Comment