Ponteiros e funçao

#include<stdio.h> #include<string.h> struct aluno{ char nome[20]; float n1,n2,media; }; typedef struct aluno Aluno; void read(Aluno *al){ //printf("digite o nome do aluno"); //fflush(stdin); //gets(al->nome); //printf("digite a N1 do aluno"); //fflush(stdin); //scanf("%f",&al->n1); //printf("digite a N1 do aluno"); //scanf("%f",&al->n2); al->n2 = 10; al->n1 = 8; } void med(Aluno *al){ al->media = (al->n1 + al->n2)/2; // printf("%f", media); } void write(Aluno al){ printf("nome:%s \n n1 == %f n2 == %f media ==%f", al.nome,al.n1,al.n2, al.media); } int main(){ Aluno al; read(&al); med(&al); write(al); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.