Help to write code

Asked

Viewed 266 times

-5

How do I use Dev-c++ with this code.
How to translate it to C?

I started recently with programming, I’m a little tied up to understand some things.

Programa CalculoMedia 
Var 
 N1, N2, MEDIA: Real 
Início 
Leia N1 
Leia N2 
MEDIA ← (N1+N2)/2 
Se MEDIA >=6 Então 
 Escreva “Aluno aprovado com média: ”, MEDIA 
 Senão 
 Escreva “Aluno reprovado com média: ”, MEDIA 
Fim Se 
Fim. 
  • 2

    But this problem only needs the basic C. language commands 15 minutes of study and you will be able to solve your homework.

  • 3

    Matheus, I returned the question to its most understandable original state, so that the answer accepted does not get out of context. If you have new doubts, even if they are about the same program, create a new question explaining your problem.

2 answers

5


To transcribe this program to c language, a method is first required main which is equivalent to instruction programa <nome>

the instructions leia and escreva should be replaced by printf and scanf, se for if and end by {

follows an example of how to syntax:

#include <stdio.h> // declara printf e scanf, usados abaixo

int main(int argc, char *argv[]) {// equivalente ao programa
    int numero; //equivalente ao var
    printf("digite um numero: "); // serve para imprimir caracteres na tela
    scanf("%d", &numero); // leitura de um valor

    if(numero > 10){ // se
        printf("numero maior que 10");
    }else{// se não
        printf("numero menor que 10");
    }// fimse
    return 0;
}// fim do programa
  • 1

    Missed the return 0;

  • I’m trying harder this by giving an error:[Warning] incompatible implicit declaration of built-in Function 'scanf' [enabled by default]

  • @matheusferreira add the #include <stdio.h> at the top.

  • @Guilhermebernal, thank you for hitting the #include.

-1

The IF is wrong missed the keys try so:

if(MEDIA >=6){
    printf ("Alunos aprovados com media: ", MEDIA);
}
    else{
    printf ("Alunos reprovados com media: ", MEDIA);
}

Browser other questions tagged

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