2
In case I want a condition to repeat several times and several times I have to use the command return
for any specific line? I will put the program to explain better:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int aprovados, auxa=0, reprovados, auxr=0, notas=0, cont=0;
while(cont<10)
{
printf("digite o resultado: ");
scanf("%i", ¬as);
if(notas==1)
auxa++;
if(notas==2)
auxr++;
if(notas!=1 && notas!=2)
{
cont--;
printf("esse valor nao eh valido digite 1 ou 2: ");
scanf("%i", ¬as);
cont++;
if(notas==1)
auxa++;
if(notas==2)
auxr++;
}
cont++;
}
printf("aprovados:%i\n", auxa);
printf("reprovados:%i\n", auxr);
if(auxa>=8)
printf("bonus ao instrutor\n");
if(auxr>=7)
printf("algo esta errado com o instrutor\n");
return 0;
}
Here’s what I want to do on the third if
if I type for example 3 it asks to type another number(I know I specified in printf
that is to type 1 or 2) but if I type 3 right after the counter counts 1 increment and if I repeat numbers that are not 1 or 2 (in case to do this 20 times half of those times will be incremented in the counter) have how I give a return
for a line specifies every time some number other than 1 or 2 is entered?
It’s hard to understand the explanation. Try writing in a more organized way, separate each idea. This even helps you understand your problem. If the problem is difficult to understand in Portuguese it will be difficult to understand in C. Do you know what the
return
does? I don’t think you need it in the program beyond where it is already. You know thecontinue
? I think he’s the one you want.– Maniero
our so many things I forgot to mark sorry the delay @bigown
– Leonardo V. De Gasperin