If I want a condition to be repeated over and over again, how can I use the return
command for a specific line? I'll put the program to better explain:
#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;
}
I want to do the following: in the 3rd if
if I type for example 3 it asks to enter another number (I know that I specified in printf
that is to type 1 or 2) but if I type 3 then the counter counts 1 increment and if I repeat numbers other than 1 or 2 (in this case 20 times half of those times will be incremented in the counter), how can I give return
to a specific line every time some number other than 1 or 2 to be typed?