Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Native VS Debugger Question Pin
Richard MacCutchan28-Jun-21 21:03
mveRichard MacCutchan28-Jun-21 21:03 
GeneralRe: Native VS Debugger Question Pin
Richard Andrew x6429-Jun-21 10:07
professionalRichard Andrew x6429-Jun-21 10:07 
GeneralRe: Native VS Debugger Question Pin
Richard MacCutchan29-Jun-21 10:16
mveRichard MacCutchan29-Jun-21 10:16 
QuestionMessage Closed Pin
27-Jun-21 5:05
Member 1496877127-Jun-21 5:05 
AnswerRe: How to verify apt install (application file ) executable installation ? Pin
Richard MacCutchan27-Jun-21 5:26
mveRichard MacCutchan27-Jun-21 5:26 
AnswerRe: How to verify apt install (application file ) executable installation ? Pin
k505427-Jun-21 5:56
mvek505427-Jun-21 5:56 
QuestionAccurate interpretation and evaluation of this "or condition": while ( x < 1 || x > 8 ) Pin
Otto Medina25-Jun-21 21:36
Otto Medina25-Jun-21 21:36 
AnswerRe: Accurate interpretation and evaluation of this "or condition": while ( x < 1 || x > 8 ) Pin
Mircea Neacsu26-Jun-21 1:25
Mircea Neacsu26-Jun-21 1:25 
You might be confused by a pair of spurious braces Smile | :)
#include <stdio.h>

int main(void)
{
    int x ; //This is the variable for being evaluated

    do
    {
    printf("Imput a figure between 1 y 8: ");
    scanf("%i", &x);

    }
    while ( x < 1 ||  x > 8 ); //This is a do...while statement.
                               //It repeats until x is between 1 AND 8

    { //this brace is not needed and might make you believe there is a while loop
        printf("Your imput was ::: %d ",x);
        printf("\n");

     } //closing brace that should also be removed
        printf("\n");

}


What the program does is to repeat the scanf statement until x is between 1 and 8.

Antoher way to explain it: the loop repeats until the condition is false. !( (x<1) || (x>8) ) is equivalent to !(x<1) && !(x>8) (see De Morgan's laws[^]), or (x>=1) && (x<=8).
Mircea

GeneralRe: Accurate interpretation and evaluation of this "or condition": while ( x < 1 || x > 8 ) Pin
Otto Medina26-Jun-21 18:51
Otto Medina26-Jun-21 18:51 
AnswerRe: Accurate interpretation and evaluation of this "or condition": while ( x < 1 || x > 8 ) Pin
Aghast (nj)26-Jun-21 3:13
Aghast (nj)26-Jun-21 3:13 
GeneralRe: Accurate interpretation and evaluation of this "or condition": while ( x < 1 || x > 8 ) Pin
Otto Medina29-Jun-21 2:30
Otto Medina29-Jun-21 2:30 
QuestionMessage Closed Pin
16-Jun-21 3:19
Member 1496877116-Jun-21 3:19 
AnswerRe: How do I access private variable of an object ? Pin
Mircea Neacsu16-Jun-21 3:23
Mircea Neacsu16-Jun-21 3:23 
GeneralMessage Closed Pin
16-Jun-21 5:50
Member 1496877116-Jun-21 5:50 
AnswerRe: How do I access private variable of an object ? Pin
Mircea Neacsu16-Jun-21 6:12
Mircea Neacsu16-Jun-21 6:12 
GeneralRe: How do I access private variable of an object ? Pin
David Crow16-Jun-21 6:37
David Crow16-Jun-21 6:37 
AnswerRe: How do I access private variable of an object ? Pin
Richard MacCutchan16-Jun-21 6:58
mveRichard MacCutchan16-Jun-21 6:58 
AnswerRe: How do I access private variable of an object ? Pin
RedDk16-Jun-21 7:22
RedDk16-Jun-21 7:22 
AnswerRe: How do I access private variable of an object ? Pin
CPallini16-Jun-21 23:27
mveCPallini16-Jun-21 23:27 
GeneralRe: How do I access private variable of an object ? Pin
Richard MacCutchan17-Jun-21 0:35
mveRichard MacCutchan17-Jun-21 0:35 
GeneralRe: How do I access private variable of an object ? Pin
CPallini17-Jun-21 1:32
mveCPallini17-Jun-21 1:32 
GeneralMessage Closed Pin
17-Jun-21 6:36
Member 1496877117-Jun-21 6:36 
GeneralRe: How do I access private variable of an object ? Pin
Richard MacCutchan17-Jun-21 6:40
mveRichard MacCutchan17-Jun-21 6:40 
GeneralRe: How do I access private variable of an object ? Pin
CPallini17-Jun-21 7:43
mveCPallini17-Jun-21 7:43 
AnswerRe: How do I access private variable of an object ? Pin
Magnus Forslund15-Jul-21 2:19
Magnus Forslund15-Jul-21 2:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.