Sponsored Content
Homework and Emergencies Homework & Coursework Questions Print questions from a questions folder in a sequential order Post 302475247 by ctsgnb on Saturday 27th of November 2010 12:12:52 PM
Old 11-27-2010
Here are some ideas :

1) you should add a specific character before every lines that start by a number.
this way, you can use this character as a record separator and retrieve questions by there records number (easy using awk)

2) you should store the total number of record/questions into a variable, because you may need it :
- if you are at the last questions and press N "Next" into the menu, you could therefore go to question 1
- if you are in question 1 and press P "Previous" then you could easily go to the last equestions.

3) Since you are going to do repeted task (display question and ask choice) you should consider building that call into a function that would take (for example) the questions number as arguments

Last edited by ctsgnb; 11-29-2010 at 06:55 AM.. Reason: Initially posted a too complete solution that wouldn't help you to learn by practice
This User Gave Thanks to ctsgnb For This Post:
 

9 More Discussions You Might Find Interesting

1. Programming

C questions

What does "extern" do? ex. extern int x; and another question, what about using static in functions? like: static void foo(), why? (2 Replies)
Discussion started by: Esaia
2 Replies

2. UNIX for Dummies Questions & Answers

questions

Dear Guys , I have some Questions , i need to have answeres for . 1. now if i took a back up for /etc/passwd and /etc/shadow , like simple copy .. and Install a new system , and paste those two files to the new system ... are the passwords and user info. going to work ?? is it posibble ? ... (1 Reply)
Discussion started by: tamemi
1 Replies

3. UNIX for Dummies Questions & Answers

few questions

hi , i have got few questions 1) i created a file "-myfile" .how can i remove this?what command shud i issue 2) i used echo "TODAYS DATE" ; DATE..........but date is comoing in second line..how can i make it come in single line? 3) how can i list all files in a directory using for... (5 Replies)
Discussion started by: vivekshankar
5 Replies

4. AIX

Basic AIX Print Queue Questions

Morning, All I've been doing some work on AIX print queues, troubleshooting some underlying issues we've been having. In the process of this I've uncovered some potential gaps in our knowledge. Our typical setup is remote impact printers (In this case OKIML5520s, with NICs) and local queues... (0 Replies)
Discussion started by: alexop
0 Replies

5. Programming

Reading special characters while converting sequential file to line sequential

We have to convert a sequential file to a 80 char line sequential file (HP UX platform).The sequential file contains special characters. which after conversion of the file to line sequential are getting coverted into "new line" or "tab" and file is getting distorted. Is there any way to read these... (2 Replies)
Discussion started by: Rajeshsu
2 Replies

6. Programming

A few C questions

Hi guys. I'm writing a basic script in C# and there's a few areas where I am stuck, and I was wondering if you may be able to help me? 1) Can you embed an image into the source code so it will show in the windows GUI? 2) Can you change the background of the GUI? 3) How do you add an .ico to... (5 Replies)
Discussion started by: JayC89
5 Replies

7. Programming

C++ questions

1.) Let's say I have a list: apple1, apple2, apple3, apple4, apple5 Does anyone know how to display the txt file using c++? Does anyone know how to insert apple6 into the text file using link list and show the whole list including apple6? (1 Reply)
Discussion started by: bscot008
1 Replies

8. UNIX for Dummies Questions & Answers

Vi questions

Hello, I would like to know how we can highlight/select a section of a file in vi and delete that section if we don't want to use the dd command to delete one line at at time. There is one where we don't want to delete the whole line , but up to a certain word. (2 Replies)
Discussion started by: Pouchie1
2 Replies

9. Shell Programming and Scripting

awk to print missing and keep sequential ordering if not found

The below awk in bold will look for the ids in file1 in $2 of file2 and if they match print the line in file2. If an id is missing or not found in file2 (like BMPR2 in line4 of file1) I can not figure out how to add it to them to the lines in the output as missing in $3 following the same format.... (4 Replies)
Discussion started by: cmccabe
4 Replies
QUIZ(6) 							 BSD Games Manual							   QUIZ(6)

NAME
quiz -- random knowledge tests SYNOPSIS
quiz [-t] [-i file] [question answer] DESCRIPTION
The quiz utility tests your knowledge of random facts. It has a database of subjects from which you can choose. With no arguments, quiz displays the list of available subjects. The options are as follows: -t Use tutorial mode, in which questions are repeated later if you didn't get them right the first time, and new questions are presented less frequently to help you learn the older ones. -i Specify an alternative index file. Subjects are divided into categories. You can pick any two categories from the same subject. quiz will ask questions from the first cate- gory and it expects answers from the second category. For example, the command ``quiz victim killer'' asks questions which are the names of victims, and expects you to answer with the cause of their untimely demise, whereas the command ``quiz killer victim'' works the other way around. If you get the answer wrong, quiz lets you try again. To see the right answer, enter a blank line. Index and Data File Syntax The index and data files have a similar syntax. Lines in them consist of several categories separated by colons. The categories are regular expressions formed using the following meta-characters: pat|pat alternative patterns {pat} optional pattern [pat] delimiters, as in pat[pat|pat]pat In an index file, each line represents a subject. The first category in each subject is the pathname of the data file for the subject. The remaining categories are regular expressions for the titles of each category in the subject. In data files, each line represents a question/answer set. Each category is the information for the question/answer for that category. The backslash character (``'') is used to quote syntactically significant characters, or at the end of a line to signify that a continuation line follows. If either a question or its answer is empty, quiz will refrain from asking it. FILES
/usr/share/games/quiz.db The default index and data files. BUGS
quiz is pretty cynical about certain subjects. BSD
May 31, 1993 BSD
All times are GMT -4. The time now is 10:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy