473,809 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Assignment: Print reverse order

1: Write a program that asks the user to input an integer value and
print it in a reverse order
Sample Output
Enter any number 65564
Reverse of 65564 is 46556

2: Write a program that takes a string as an input and print it in
reverse order.(don't use bulit-in/library function).
Sample Output
Enter any string: i m Kashif
Reverse of
i m kashif
is
fihsak m i

Apr 12 '06 #1
10 5400
aa******@gmail. com wrote:
1: Write a program that asks the user to input an integer value and
print it in a reverse order
Sample Output
Enter any number 65564
Reverse of 65564 is 46556

2: Write a program that takes a string as an input and print it in
reverse order.(don't use bulit-in/library function).
Sample Output
Enter any string: i m Kashif
Reverse of
i m kashif
is
fihsak m i


So what's your question?

Robert Gamble

Apr 12 '06 #2
"aa******@gmail .com" <aa******@gmail .com> writes:
1: Write a program that asks the user to input an integer value and
print it in a reverse order
Sample Output
Enter any number 65564
Reverse of 65564 is 46556
Done.
2: Write a program that takes a string as an input and print it in
reverse order.(don't use bulit-in/library function).
Sample Output
Enter any string: i m Kashif
Reverse of
i m kashif
is
fihsak m i


Done.

I'm not sure why you wanted me to write those programs, but I had fun
writing them. Thanks.

(Perhaps you were looking for comp.lang.c.do. my.homework.for .me?)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 12 '06 #3
<aa******@gmail .com> wrote:
1: Write a program that asks the user to input an integer value and
print it in a reverse order
Sample Output
Enter any number 65564
Reverse of 65564 is 46556

2: Write a program that takes a string as an input and print it in
reverse order.(don't use bulit-in/library function).
Sample Output
Enter any string: i m Kashif
Reverse of
i m kashif
is
fihsak m i


You have posted three problems you have been assigned. The second problem
above is the easiest and clearest. Focus on that one instead of flailing
around. Do you know how to read a string into memory? If not, concentrate
on that first.

The comment about clarity relates to problem 1 above. A user has no idea of
what an integer is unless you tell him. Is 123456789123456 789 an integer?
Unless you tell me otherwise it is, indeed, an integer. Note that one can
read question 2 to have the same meaning, with a different datum as question
1.
Apr 12 '06 #4
ed
On 12 Apr 2006 08:53:11 -0700
"aa******@gmail .com" <aa******@gmail .com> wrote:
1: Write a program that asks the user to input an integer value and
print it in a reverse order
Sample Output
Enter any number 65564
Reverse of 65564 is 46556
#include <stdio.h>

int main() {
print( "it in a reverse order\n" );
return(0);
}

2: Write a program that takes a string as an input and print it in
reverse order.(don't use bulit-in/library function).
Sample Output
Enter any string: i m Kashif
Reverse of
i m kashif
is
fihsak m i


See answer to q1.

Sorry if you feel I am being pedantic. Please don't just post your home
work questions, at least have a go, send your attempt along with the
question and any errors which you are getting.

--
Regards, Ed :: http://www.s5h.net
:%s/\t/ /g :: proud unix system person
:%s/Open Source/Free Software/g
Apr 12 '06 #5
aa******@gmail. com wrote:
1: Write a program that asks the user to input an integer value and
print it in a reverse order
Sample Output
Enter any number 65564
Reverse of 65564 is 46556
#include <stdio.h>
int main(void)
{
puts("Please input an integer value and print it in a reverse order\n"
"Sample Output\n"
"Entry any number 65564\n"
"Reverse of 65564 is 46556");
return 0;
}

OK, that's done. The above asks the user to input a value and print it
as requested. It might be more helpful if it told the user where to
input the value and where to print it, but that was not in the
specification.
2: Write a program that takes a string as an input and print it in
reverse order.(don't use bulit-in/library function).
Sample Output
Enter any string: i m Kashif
Reverse of
i m kashif
is
fihsak m i


You can't write a program to take inpput from a user and produce output
without using library functions (even getc/putc might use library
functions).

If you want code written for you then my current out of hours rate is
500UKP per hour or part there of with a minimum charge of 5000UKP. To
get the work done in my normal working hours you will have to contact my
employer, however I'm already booked up till well in to next year so
that would probably not do you.

In other words, if you don't even try to do your homework why should we
do it for you? I certainly don't want people passing courses on that
basis since I might have to deal with their inability to program if they
get a job later!
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Apr 12 '06 #6
aa******@gmail. com wrote:
1: Write a program that asks the user to input an integer value and
print it in a reverse order
Sample Output
Enter any number 65564
Reverse of 65564 is 46556
Is this trivial or what?
Trivial approach 1: Look up the '%' and '/' operators for integer values.
Trivial approach 2: Since your assignment does not require you to read
the interger as an integer, just fgets() the string and print it out
backwards.
2: Write a program that takes a string as an input and print it in
reverse order.(don't use bulit-in/library function).


All I/O for C programs uses streams and library functions. Your
assignment is impossible.

Apr 12 '06 #7
Keith Thompson wrote:
"aa******@gmail .com" <aa******@gmail .com> writes:

2: Write a program that takes a string as an input and print it in
reverse order.(don't use bulit-in/library function).
Sample Output
Enter any string: i m Kashif
Reverse of
i m kashif
is
fihsak m i

Done.


I don't believe you.
Apr 12 '06 #8
Martin Ambuhl <ma*****@earthl ink.net> writes:
Keith Thompson wrote:
"aa******@gmail .com" <aa******@gmail .com> writes:

2: Write a program that takes a string as an input and print it in
reverse order.(don't use bulit-in/library function).
Sample Output
Enter any string: i m Kashif
Reverse of i m kashif is fihsak m i

Done.


I don't believe you.


Ok, I glossed over the "don't use bulit-in/library function" requirement.

I avoided using any library functions in the reversal code.
I did use library functions for I/O.

I also ignored the discrepancy between "Kashif" and "kashif", assuming
it to be a typo.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 12 '06 #9

"Keith Thompson" <ks***@mib.or g> wrote in message
news:ln******** ****@nuthaus.mi b.org...
Martin Ambuhl <ma*****@earthl ink.net> writes:
Keith Thompson wrote:
"aa******@gmail .com" <aa******@gmail .com> writes:

2: Write a program that takes a string as an input and print it in
reverse order.(don't use bulit-in/library function).
Sample Output
Enter any string: i m Kashif
Reverse of i m kashif is fihsak m i
Done.


I don't believe you.


Ok, I glossed over the "don't use bulit-in/library function" requirement.

I avoided using any library functions in the reversal code.
I did use library functions for I/O.

I also ignored the discrepancy between "Kashif" and "kashif", assuming
it to be a typo.


What? Your wasting your time on this, when you could be ripping my FUBAR'd
realloc() to shreds? "Spec. kiddy" (yes, that's a bad play on "script
kiddy") you're losing it. If you were ripping my realloc(), you still
wouldn't have to post any code...at all...like usual...
Rod Pemberton


Apr 13 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
3241
by: Paul Rubin | last post by:
OK, I want to scan a file for lines matching a certain regexp. I'd like to use an assignment expression, like for line in file: if (g := re.match(pat, line)): croggle(g.group(1)) Since there are no assignment expressions in Python, I have to use a temp var. That's a little more messy, but bearable:
3
3408
by: R. Rajesh Jeba Anbiah | last post by:
Unfortunately, I couldn't find any way to traverse the object array in reverse order. I'd thought there must be a way to do it with for..in loop, but couldn't find anything yet. Could someone please help me? TIA. -- <?php echo 'Just another PHP saint'; ?> Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/
166
8699
by: Graham | last post by:
This has to do with class variables and instances variables. Given the following: <code> class _class: var = 0 #rest of the class
8
7610
by: vijay | last post by:
Hello, As the subject suggests, I need to print the string in the reverse order. I made the following program: # include<stdio.h> struct llnode { char *info;
10
2603
by: Christian Christmann | last post by:
Hi, how do I define an assignment operator which is supposed to copy all member attributes of one object to another where both objects are given as pointers? Example: CLASS_A *source = new CLASS_A; ....
9
4191
by: aatish19 | last post by:
Write a program that asks the user to input any amount as an integer number and display it in words Sample output: Enter any amount : 4562 Four thousend five hundred sixty two
37
2798
by: Tim N. van der Leeuw | last post by:
Hi, The following might be documented somewhere, but it hit me unexpectedly and I couldn't exactly find this in the manual either. Problem is, that I cannot use augmented assignment operators in a nested scope, on variables from the outer scope: PythonWin 2.4.3 (#69, Mar 29 2006, 17:35:34) on win32. Portions Copyright 1994-2004 Mark Hammond (mhammond@skippinet.com.au) -
6
18112
by: raghuveer | last post by:
i want to print my linked list in the reverse order ie..last item first and first item last..this is what i have so far struct linked_list { int number; struct linked_list *next; }; typedef linked_list node;
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10387
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.