Sponsored Content
Full Discussion: Loops question
Homework and Emergencies Homework & Coursework Questions Loops question Post 302887557 by jim mcnamara on Saturday 8th of February 2014 06:22:35 PM
Old 02-08-2014
Code:
int k=1;
while (k==1)

{
 
    if(d1 && d2 && d3 <= ra && rb && rc)
    {
      cerr << "Circles A B and C contain point (" << xq << " ," << yq << "). " << endl;
      exit (10);
    }

    else if (d1 && d3 <= ra && rc && d2 >= rb)
    {
      cerr << "Circles A and C contain point (" << xq << " ," << yq << "). " << endl;
      exit(20);
    }

    else if (d3 >= rc && d2 && d2 <= ra && rb)
    {
      cerr << "Circles A and B contain point (" << xq << " ," << yq << "). " << endl;
      exit(30);
    }

  else if (d1 >= ra && d2 <= rb && d3 <= rc)
    {
      cerr << "Circles B and C contain point (" << xq << " ," << yq << "). " << endl;
      exit(40);
    }

  else if (d2 && d3 >= rb && rc && d1 <= ra)
    {
      cerr << "Circle A contains point (" << xq << " ," << yq << "). " << endl;
      exit(50);
    }

  else if (d1 && d3 >= ra && rc && d2 <= rb)
    {
      cerr << "Circle B contains point (" << xq << " ," << yq << "). " << endl;
      exit(60);
    }

  else if (d1 && d3 >= ra && rc && d2 <= rb)
    {
      cerr << "Circle C contains point (" << xq << " ," << yq << "). " << endl;
      exit(70);
    }
   
  else if (d1 && d2 && d3 >= ra && rb && rc)
    {
      cerr << "No circle contains point (" << xq << " ," << yq << "). " << endl;
      exit(80);
    }
 
 }

The loop does not exit because k is never changed (or referenced) inside the loop. Your code had several problems. Note the read areas. You MUST COMPILE with WARNINGS enabled! Correct code has ZERO warnings. At a minimum, assuming the logic is correct. The code you posted could not have compiled without warnings. You still need to set k to zero somewhere in the loop code.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

While loops

Hi all, I am an amateur k shell scripter and came across something I need clarification on. while ; do various commands done What is the "" condition testing for in the above while loop? THx, Bookoo (5 Replies)
Discussion started by: bookoo
5 Replies

2. UNIX for Dummies Questions & Answers

While Loops

I'm trying to create a loop that will prompt the user for 15 values, not forcing them to enter all 15. If the user enters through one or more of the prompts the null value needs to be converted to 0, otherwise set the parameter = to the value entered: ex. Please enter file no #1: 17920 ... (4 Replies)
Discussion started by: vdc
4 Replies

3. Shell Programming and Scripting

ksh question, loops

i want to add about 60 printers using a ksh script. i am having trouble though, i am reading the input from the hosts file and using the lpadmin command to add like so: lpadmin -p -v /dev/null -m netstandard -o dest= i want printername and ipaddy to come from the hosts file, i am having... (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

4. Shell Programming and Scripting

Help with the 2 for loops

#!/bin/bash IFS=$'\n' A= a c b t g j i e d B= t y u i o p counter=0 found="" for i in $(cat $A) do for j in $(cat $B) do if then found="yes" fi done if then (1 Reply)
Discussion started by: vadharah
1 Replies

5. Shell Programming and Scripting

Help with loops

I am trying to do ftp of some crt files that have spaces in the file names. I have to do approximately 4500 files ftp'ed and then check whether the trasnfered file size matches the source files. This has to be in a loop I mean 1. ftp the file, check for file size whether the source and target... (0 Replies)
Discussion started by: dsravan
0 Replies

6. Shell Programming and Scripting

loops

Hi All I have some directories on our server which are containing .csv files. i need to print value of cell "B2" from those csv files. Please advise. I have tried head command as example: head -2 */Book_Collection_Report_1_-_Collection_Requests_trials.csv | sed -n "3p" | awk -F","... (4 Replies)
Discussion started by: yash1978
4 Replies

7. UNIX for Dummies Questions & Answers

Bourne-sh (not bash) question about nested loops and sed

Here's the input: alpha, numeric or alphanumeric string ("line 1 string") numeric string ("line 2 string") numeric string ("line 3 string") numeric string ("line 4 string") ... where - each numeric string is in a pattern that can be matched with RE but - there can be any number of... (2 Replies)
Discussion started by: uiop44
2 Replies

8. Shell Programming and Scripting

Loops

Hi All, I am very new to Shell scripting. I read basic scripting manual. But i didn't understand the code. Please tell the meaning of the below code: while getopts "F:f:R:r:C:c:" opt 2>/dev/null do case ${opt} in F|f) FREQUENCY_MODE=$OPTARG;; ... (3 Replies)
Discussion started by: pdathu
3 Replies

9. Homework & Coursework Questions

If and Loops

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: In this script you will take a directory as input from the user and change the end of line sequence from a Unix... (1 Reply)
Discussion started by: Pcarson
1 Replies

10. UNIX for Advanced & Expert Users

Help with loops?

I'm trying to understand better the while and until loops, can someone help me with this example? #!/bin/bash # Listing the planets. for planet in Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Pluto do echo $planet # Each planet on a separate line. done echo; echo for... (3 Replies)
Discussion started by: jose2802
3 Replies
DROP TEXT SEARCH 
TEMPLATE(7) PostgreSQL 9.2.7 Documentation DROP TEXT SEARCH TEMPLATE(7) NAME
DROP_TEXT_SEARCH_TEMPLATE - remove a text search template SYNOPSIS
DROP TEXT SEARCH TEMPLATE [ IF EXISTS ] name [ CASCADE | RESTRICT ] DESCRIPTION
DROP TEXT SEARCH TEMPLATE drops an existing text search template. You must be a superuser to use this command. PARAMETERS
IF EXISTS Do not throw an error if the text search template does not exist. A notice is issued in this case. name The name (optionally schema-qualified) of an existing text search template. CASCADE Automatically drop objects that depend on the text search template. RESTRICT Refuse to drop the text search template if any objects depend on it. This is the default. EXAMPLES
Remove the text search template thesaurus: DROP TEXT SEARCH TEMPLATE thesaurus; This command will not succeed if there are any existing text search dictionaries that use the template. Add CASCADE to drop such dictionaries along with the template. COMPATIBILITY
There is no DROP TEXT SEARCH TEMPLATE statement in the SQL standard. SEE ALSO
ALTER TEXT SEARCH TEMPLATE (ALTER_TEXT_SEARCH_TEMPLATE(7)), CREATE TEXT SEARCH TEMPLATE (CREATE_TEXT_SEARCH_TEMPLATE(7)) PostgreSQL 9.2.7 2014-02-17 DROP TEXT SEARCH TEMPLATE(7)
All times are GMT -4. The time now is 09:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy