Explanation of the code

Asked

Viewed 70 times

-2

Hello, could you explain the part of that code?

int nota[2];
    scanf( "%s %d", nome, &horas );

And that part

int i = 0;

    while( i < 2 ) {
        scanf( "%d", &nota[i] );
        if( nota[i] > 100 || nota[i] < 0 ) {
            // printf( "Nota fora do intervalo\n" );
        } else {
            i++;
        }
    }

    //Media Ponderada
    float calculo = media * 0.4 + nota[0] * 0.1 + nota[1] * 0.5;

    if( nota[1] < 70 ) {

While (i < 2), **note[i], note[0], note[1] and note[2]

  • Post the complete code. In what you have posted missing definitions of variables and also calculations (for example calculation or media reading). The last line doesn’t make sense.

  • @anonymo I can post on a website for access to part.

1 answer

0

int nota[2]; <- cria uma variável na forma de array com 2 posicoes
    scanf( "%s %d", nome, &horas );// <- recebe a informação digitada no cmd



int i = 0;

    while( i < 2 ) {// <- estrutura de repetição que ira fazer até que o 'i' seja menor que 2
        scanf( "%d", &nota[i] );
        if( nota[i] > 100 || nota[i] < 0 ) { //<- ira verificar se a nota de posição 'i' é maior que 100  ou menor que 0
            // printf( "Nota fora do intervalo\n" );
        } else {
            i++;
        }
    }

    //Media Ponderada
    float calculo = media * 0.4 + nota[0] * 0.1 + nota[1] * 0.5;

    if( nota[1] < 70 ) {
  • And the note[0] ?

  • refers to the first value of the note. In computation it starts counting from 0

  • Dba, could you find me in contact?

  • I will update my profile with facebook then you enter there.

  • I’ll be standing by. Att.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.