|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
C
DETAILS
Question: Write a program to accept any number up to six digit and print in words. for ex:1234=one two three four
Answer: #include<stdio.h> void main() { long int number,r,rev=0,rem; printf("Enter any number"); scanf("%ld",&number); while(number!=0) { r=number%10; rev=(rev*10)+r; number/=10; } while(rev!=0) { rem=rev%10; switch(rem) { 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 0: printf("zero "); break; } rev/=10; } }
|
|
|
Category |
C Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 8467 users |
Added on |
12/19/2013 |
Views |
72047 |
Rate it! |
|
|
Question:
Write a program to accept any number up to six digit and print in words. for ex:1234=one two three four
Answer:
#include<stdio.h> void main() { long int number,r,rev=0,rem; printf("Enter any number"); scanf("%ld",&number); while(number!=0) { r=number%10; rev=(rev*10)+r; number/=10; } while(rev!=0) { rem=rev%10; switch(rem) { 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 0: printf("zero "); break; } rev/=10; } } Source: CoolInterview.com
Answered by: pavan kumar | Date: 12/22/2008
| Contact pavan kumar
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What is type integration? And what is integer type integration?
|
View Answer
|
|
What is :- Token , identifier , block , parameter , argument , scope of variable , Macro ?
|
View Answer
|
|
What is the code to find our age,for example if my date of birth is 4/12/1986 and today date is 16/11/2008 answer should give our year,month,no of days
|
View Answer
|
|
What is the difference between unix and linux.
|
View Answer
|
|
How to convert decimal to octal and hexadecimal?
|
View Answer
|
|
If we want that any wildcard characters in the command line argument should be approxiemately expanded , are we required to make any special provision?if yes, which?
|
View Answer
|
|
How would you obtain the current time and difference between two times?
|
View Answer
|
|
What is a default TCP/IP socket assigned for SQL Server?
|
View Answer
|
|
#include <stdio.h> int main() {
int a=3, b = 5; printf(&a["Ya!Hello! how is this? %s "], &b["junk/super"]); printf(&a["WHAT%c%c%c %c%c %c ! "], 1["this"], 2["beauty"],0["tool"],0["is"],3["sensitive"],4["CCCCCC"]);
return 0; }
|
View Answer
|
|
How i can run *.bat or *.cmd file by using system function in c ?
|
View Answer
|
|
Why does a linker error occurs for the segment: main() { extern int i; i=20; printf("%d",sizeof(i)); }
|
View Answer
|
|
Can there be a mouse click and drag function used together to rotate a circle in c?please give which are they?
|
View Answer
|
|
Can there be a mouse click and drag function used in c?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All C Interview Questions & Answers - Exam Mode /
Learning Mode
|