Escolar Documentos
Profissional Documentos
Cultura Documentos
estruturas de dados I
Módulos
Elverton Fazzion
#include <stdio.h>
int main(){
double a, b, c, d;
printf(“Insira os coeficientes (a, b, c) e x:”);
scanf(“%lf %lf %lf %lf”, &a, &b, &c, &d);
double y = calcula_equacao(a, b, c, d);
printf(“Y=%.2lf\n”, y);
return 0;
}
int main(){
double a, b, c, d;
printf(“Insira os coeficientes (a, b, c) e x:”);
scanf(“%lf %lf %lf %lf”, &a, &b, &c, &d);
calcula_equacao(a, b, c, d);
return 0;
}
tipo_retorno nome_função(parâmetros);
○ Exemplo:
int main(){
double a, b, c, d;
printf(“Insira os coeficientes (a, b, c) e x:”);
scanf(“%lf %lf %lf %lf”, &a, &b, &c, &d);
calcula_equacao(a, b, c, d);
return 0;
}
#include <stdio.h>
int main(){
double a, b, c, d;
printf(“Insira os coeficientes (a, b, c) e x:”);
scanf(“%lf %lf %lf %lf”, &a, &b, &c, &d);
calcula_equacao(a, b, c, d);
return 0;
}
Paramos a
compilação
aqui!
Programa Programa Programa
Compilador Ligador Executável
Fonte Objeto
Programa
Objeto das
Bibliotecas
int main(){
double a, b, c, d;
printf(“Insira os coeficientes (a, b, c) e x:”);
scanf(“%lf %lf %lf %lf”, &a, &b, &c, &d);
calcula_equacao(a, b, c, d);
return 0;
}
Programa
Objeto das
Bibliotecas
Programa objeto
#include “retangulo.h”
#include <stdio.h>
int main(){
double a = 2.0, b = 3.0;
printf(“Perimetro: %lf\n”, perimetro_retangulo(a, b));
printf(“Área: %lf\n”, area_retangulo(a, b));
printf(“Diagonal: %lf\n”, diagonal_retangulo(a, b));
return 0;
}
retangulo.h
#include “retangulo.h”
#include <math.h>
main.o: main.c
<TAB> gcc -c main.c
main.o: main.c
<TAB> gcc -c main.c
main.o: main.c
<TAB> gcc -c main.c
main.o: main.c
Executa o comando <TAB> gcc -c main.c
da regra, gerando o
main.o retangulo.o: retangulo.c retangulo.h
<TAB> gcc -c retangulo.c
main.o: main.c
Resolve a segunda <TAB> gcc -c main.c
dependência para
gerar retangulo.o retangulo.o: retangulo.c retangulo.h
<TAB> gcc -c retangulo.c
main.o: main.c
<TAB> gcc -c main.c
clean:
<TAB> rm *.o
Elverton Fazzion