Click here to Skip to main content
15,902,926 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Your goal is to read a 68-word text from the input and then print it to the screen backward. Individual words do not have to be spelled backward, but rather your program should print out the last word first, then the second-to-last word, etc. No word has more than 40 characters.

Example

Input
Science Computer on Papers Selected Knuth, Ervin Donald ― correct." be will results that reader a convince to and works algorithm and way the communicate to concepts, mathematical as well as forms literary and aesthetic tradition with works who essayist and ideally is programmer A clearly. they understand can beings human that so and quickly them perform can machine computing that so written are programs best "The

Output
"The best programs are written so that computing machines can perform them quickly and so that human beings can understand them clearly. A programmer is ideally an essayist who works with traditional aesthetic and literary forms as well as mathematical concepts, to communicate the way an algorithm works and to convince a reader that the results will be correct." ― Donald Ervin Knuth, Selected Papers on Computer Science using visual studio only


What I have tried:

its very very complicated i dont know where to start from
Posted
Updated 25-May-22 21:06pm

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

Think about what the question is asking you to do, and how you would do it manually. That at least gives you the "shape" of the application, and you can then begin "fleshing out" that shape to a design.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
Comments
OsayiEmmanuel Igbineweka 25-May-22 16:04pm    
and for your information its not for an assignment nether am i getting paid for it i decided to learn c program and this question gave me problems
jeron1 25-May-22 16:24pm    
Can you solve this on paper?
OriginalGriff 25-May-22 17:16pm    
Then you are learning it the wrong way.
For starters, I wouldn't begin learning with C - it's too old, too many pitfalls: only really used for maintenance (in which case you really need to know the language and how to code before you can do anything useful) or very specialised embedded work (in which case you really , really need to know the language and how to code before you can do anything useful). And if you don't know how to start with a problem like this, then you need to learn a good amount of C and practice the simpler exercises before you get to slightly complicated stuff like this!

Instead, consider learning C# - it looks much the same but it's a lot newer and much easier to work with because it's a lot "stricter". Go on a course (best way), get a book (Wrox, Addison Wesley, and MS Press do good ones), and avoid YouTube "tutorials" like the plague.
MS will give you a copy of Visual Studio which will help you edit, compile, and debug your code for free (search MS for "Visual Studio Community" and you'll find it).
merano99 25-May-22 19:43pm    
There are many reasons to learn C or C++.
https://www.niit.com/india/knowledge-centre/reasons-to-learn-C-programming-language

I think it's nonsense that C can only really be used for maintenance.
Whether this exercise is too difficult for a beginner depends on whether the problem can be broken down into small enough simple steps. That would be what you always need, regardless of a programming language.
CPallini 26-May-22 1:55am    
5.
This is not complicated at all. You need to think about the problem step-by-step.

1. You're going to read a file, so do you know how to open a file?

2. You're going to need an array that holds strings. Do you know how to define an array for that?

3. You need to be able to use an index to get at elements in an array. Do you know how to do that?

4. You need to print the strings to the screen. Do yo uknow how to do that?

Once you have all the pieces, you need to put them together.
 
Share this answer
 
v2
Comments
merano99 25-May-22 20:59pm    
I would expand the list a bit more to accomplish the task:
5. Find the beginning and end of a word
6. Output of a substring with one word
7. Programming a loop that prints the words in the desired order.
(Alternatively, advanced programmers could choose recursive output.)
CPallini 26-May-22 1:55am    
5,
merano99 26-May-22 2:02am    
also 5
Quote:
How do I solve this question on multi-dimensional arrays (matrices) in C programming languages

What are you talking about ? There is no multi-dimensional arrays or matrices.
This problem is a single string or char array (in C).
Quote:
its very very complicated i dont know where to start from

No, in fact this is very easy. If you are unable to device a solution strait, start with easier tasks and make then more complicated, step by step.
- print the string char by char.
- print the string char by char in reverse order.
- print the string with 1 word per line.
- print the string with 1 word per line, in reverse order.

You are learning by trial and error, every fail is a knowledge of what don't work.

To get more help, show your work and tell us what is your problem.
 
Share this answer
 
Comments
merano99 26-May-22 1:07am    
Right, the heading with multidimensional arrays (matrices) surprised me too.
Perhaps the original plan was to first write the 68 words, each with a maximum of 40 bytes, into a char matrix?

Top tutorial Patrice, my 5 for that.
Patrice T 26-May-22 1:17am    
Thank you.
CPallini 26-May-22 1:54am    
5,
Patrice T 26-May-22 2:01am    
Thank you.
If this question has really to be solved with multidimensional arrays(matrices) in C, this would be a solution :

1. declare dimension
C
#define dim_x  40
#define dim_y  68
2. open the input (file or stdin)
3. declare matrix
C
char wordmat[dim_y][dim_x + 1];
4. read all chars from input to matrix in loop
5. close file if opened
6. output matrix in a loop with last row first

It would not be a good solution in terms of memory consumption and scalability, but it would satisfy the requirement of a multidimensional matrix solution.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900