Can anyone please help me to write a program in C?
-
I am asked to write a program in C in which if i enter a three digit- value (say 123), I should get the reverse of the value (i.e. 321) please help..
-
Answer:
its very simple... i hope you know printf, scanf, data types, getch and %(module)....If u know this, ur programs 25% ready... Now, think of the logic for reversing three digit number, you want individual digit of each number...(i.e. say 1,2 &3 in 123) and after that u interchange the place value.. Heres the program :- #include<stdio.h> #include<conio.h> void main() { int a,b,c,d,e,f; clrscr(); printf("Enter a three-digit value "); scanf("%d",&a); b=a%10; c=a/10; d=c%10; e=c/10; f=b*100+d*10+e; printf("\n\nReverse of the value = %d",f); getch(); } Hope it helped...!!
joey at Yahoo! Answers Visit the source
Other answers
You can use the functions gets to get the string of values you enter and strrev for getting the reverse of it.. It would work for strings of any length.. Here's the simplest code of t.. Hope it helps #include<stdio.h> #include<string.h> main() { char arr[100]; printf("Enter a string to reverse\n"); gets(arr); strrev(arr); printf("Reverse of the string is//: %s\n",arr); return 0; }
Raksani
include <stdio.h> int main() { int nos = 0; int res = 0; printf("Enter a Number to reverse\n"); scanf("%d", &nos); while(nos != 0) { res *= 10; res += nos % 10; nos = nos /10; } printf("Reverse is [%d]\n", res); } But this program has some limits..
Jag
Related Q & A:
- Can anyone PLEASE help me get into my e-mail?Best solution by Yahoo! Answers
- Could anyone please help me make a good msn name :D?Best solution by Yahoo! Answers
- Can anyone please recommend a good staff agency to help me find an entry level business analyst position?Best solution by jobsearch.about.com
- Can someone please help me to make a hotmail.fr address?Best solution by Yahoo! Answers
- Can you please help me write a poem?Best solution by wikihow.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.