Skip to main content

Linguagem C_Exercicios Propostos Solucao_11

Page 1

Linguagem C 25.ª Edição Atualizada e Aumentada FCA Editora (c) 2025

11

EXERCÍCIOS PROPOSTOS – SOLUÇÃO 11.1 1: #include <stdio.h> 2: #include <string.h> 3: #include <stdlib.h> /* Função exit */ 4: #include <ctype.h> /* Função toupper */ 5: 6: #define FICH "dados.dat" /* Ficheiro com os Dados */ 7: 8: #define OP_INSERIR '1' 9: #define OP_ALTERAR '2' 10: #define OP_APAGAR '3' 11: #define OP_LISTAR '4' 12: #define OP_PESQUISAR '5' 13: 14: #define OP_SAIR '0' 15: 16: #define OP_PESQ_IDADE '1' 17: #define OP_PESQ_NOME '2' 18: 19: char *mainMenu[]={ 20: "1. Inserir Registo", 21: "2. Alterar Registo", 22: "3. Apagar Registo", 23: "4. Listar Registos", 24: "5. Pesquisas", 25: "0. Sair", 26: NULL /* Acabaram as Opções */ 27: }; 28: 29: char *searchMenu[]={ 30: "1. Pesquisar por Intervalo de Idades", 31: "2. Pesquisar por Nome", 32: "0. Voltar", 33: NULL /* Acabaram as Opções */ 34: }; 35: 36: typedef struct 37: { 38: char nome[30+1]; 39: int idade; 40: float salario; 41: char status; /* '*' Indica que o registo esta apagado */ 42: } PESSOA; 43: 44: void mensagem(char *msg); 45: 46: /* Lê os dados de um registo introduzidos pelo utilizador */ 47: void ler_pessoa(PESSOA *p) 48: { 49: printf("Nome : "); gets(p->nome); 50: printf("Idade : "); scanf("%d", &p->idade); 51: printf("Salario : "); scanf("%f", &p->salario); 52: p->status=' ';

© FCA

1


Turn static files into dynamic content formats.

Create a flipbook
Linguagem C_Exercicios Propostos Solucao_11 by Grupo Lidel - Issuu