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
lmfsetup(8)						      System Manager's Manual						       lmfsetup(8)

Name
       lmfsetup - License Management Facility PAK registration script

Syntax
       /etc/lmfsetup [ template ]

Description
       The  script allows you to register data supplied by a Product Authorization Key (PAK).  The script prompts you for the data associated with
       each of the fields on a PAK.  When all the data has been entered, the License Management Facility (LMF) ensures there are  entries  against
       all  the mandatory fields, and that the Checksum validates all the license data.  If the data has been entered correctly, the PAK is regis-
       tered in the License Database.  If the data has been entered incorrectly, the appropriate error message is displayed and you are given  the
       opportunity to re-enter the data.

       The template option allows you to register license data from templates in A template containing a partially complete PAK is created by some
       products as part of their installation process.	The script only prompts you for data on the fields that are empty in the template.  If the
       script cannot find the specified template in it searches the current directory.

       The  script  is	provided as an alternative to the command.  This displays a template, which includes the fields on the PAK, and invokes an
       editor so that you can add the license data to the appropriate field.  The command also allows errors to be corrected without having to re-
       enter all the data.

See Also
       lmf(8)
       Guide to Software Licensing

																       lmfsetup(8)
All times are GMT -4. The time now is 04:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy