PROGRAMA DE CADASTRO EM C - TUTORIAL PASSO A PASSO (2024)
Vídeo onde eu ensino do zero como você faz para criar um programa/sistema de cadastro simples na linguagem de programação C. O vídeo original tem mais de 1 hora de duração, eu tive que me esforçar muito para diminuir para 16 minutos sem que a explicação ficasse ruim.
Aproveitem!
CÓDIGO FEITO NO VÍDEO (tive que retirar os símbolos de "menor que" e "maior que" e substituir pela palavra, pois o youtube não permite na descrição):
#include menor que stdio.h maior que
#include menor que string.h maior que
typedef struct {
char Name[50];
float Price;
int Quantity;
}Product;
typedef struct {
int Id;
Product Products[99];
float Total;
}Order;
int main() {
int status = 1, id = 0, c;
Order orders[99];
while(status) {
printf("\e[1;1H\e[2J");
printf("\nChoose an option: ");
int option;
scanf("%d", &option);
switch(option) {
case 1:
printf("\e[1;1H\e[2J");
orders[id].Id = id;
printf("\nOrder ID: %d", id + 1);
float total = 0;
for(int i = 0; i menor que 99; i++){
while((c = getchar()) != '\n' && c != EOF);
printf("\nEnter the name of the product: ");
char name[50];
fgets(name, sizeof(name), stdin);
printf("\nEnter the price of the product: ");
float price;
scanf("%f", &price);
printf("\nEnter the quantity of the product: ");
int quantity;
scanf("%d", &quantity);
Product product = {.Price = price, .Quantity = quantity};
strcpy(product.Name, name);
orders[id].Products[i] = product;
total += price * quantity;
printf("\nDo you want to add another product? [y/n] ");
char newProduct;
scanf(" %c", &newProduct);
if (newProduct != 'y'){
break;
}
}
orders[id].Total = total;
id++;
break;
case 2:
printf("\e[1;1H\e[2J");
for(int i = 0; i menor que id; i++){
printf("\nOrder ID: %d", i + 1);
for(int j = 0; j menor que 99; j++){
printf("\nProduct #%d", j + 1);
printf("\nProduct's name: %s", orders[i].Products[j].Name);
printf("\nProduct's price: %f", orders[i].Products[j].Price);
printf("\nProduct's quantity: %d", orders[i].Products[j].Quantity);
if(orders[i].Products[j + 1].Quantity == 0){
break;
}
}
printf("\nTotal: %f", orders[i].Total);
}
printf("\nPress any key to continue...");
while((c = getchar()) != '\n' && c != EOF);
getchar();
break;
case 3:
status = 0;
break;
}
}
return 0;
}
CÓDIGO "EMBELEZADO", FORMATADO E COMENTADO:
https://github.com/Abnersampf/Simple-Purchasing-Program/blob/main/test.c
00:00 - Apresentação do programa
01:46 - Início do programa
01:55 - Criando as duas Structs
03:01 - Loop que controla o programa
04:07 - Controlando o encerramento do programa
04:17 - Criando o cadastro
10:28 - Criando a listagem
14:09 - Ajustes finais
15:02 - Rodando o programa
16:33 - Fim
Видео PROGRAMA DE CADASTRO EM C - TUTORIAL PASSO A PASSO (2024) канала mPOV
Aproveitem!
CÓDIGO FEITO NO VÍDEO (tive que retirar os símbolos de "menor que" e "maior que" e substituir pela palavra, pois o youtube não permite na descrição):
#include menor que stdio.h maior que
#include menor que string.h maior que
typedef struct {
char Name[50];
float Price;
int Quantity;
}Product;
typedef struct {
int Id;
Product Products[99];
float Total;
}Order;
int main() {
int status = 1, id = 0, c;
Order orders[99];
while(status) {
printf("\e[1;1H\e[2J");
printf("\nChoose an option: ");
int option;
scanf("%d", &option);
switch(option) {
case 1:
printf("\e[1;1H\e[2J");
orders[id].Id = id;
printf("\nOrder ID: %d", id + 1);
float total = 0;
for(int i = 0; i menor que 99; i++){
while((c = getchar()) != '\n' && c != EOF);
printf("\nEnter the name of the product: ");
char name[50];
fgets(name, sizeof(name), stdin);
printf("\nEnter the price of the product: ");
float price;
scanf("%f", &price);
printf("\nEnter the quantity of the product: ");
int quantity;
scanf("%d", &quantity);
Product product = {.Price = price, .Quantity = quantity};
strcpy(product.Name, name);
orders[id].Products[i] = product;
total += price * quantity;
printf("\nDo you want to add another product? [y/n] ");
char newProduct;
scanf(" %c", &newProduct);
if (newProduct != 'y'){
break;
}
}
orders[id].Total = total;
id++;
break;
case 2:
printf("\e[1;1H\e[2J");
for(int i = 0; i menor que id; i++){
printf("\nOrder ID: %d", i + 1);
for(int j = 0; j menor que 99; j++){
printf("\nProduct #%d", j + 1);
printf("\nProduct's name: %s", orders[i].Products[j].Name);
printf("\nProduct's price: %f", orders[i].Products[j].Price);
printf("\nProduct's quantity: %d", orders[i].Products[j].Quantity);
if(orders[i].Products[j + 1].Quantity == 0){
break;
}
}
printf("\nTotal: %f", orders[i].Total);
}
printf("\nPress any key to continue...");
while((c = getchar()) != '\n' && c != EOF);
getchar();
break;
case 3:
status = 0;
break;
}
}
return 0;
}
CÓDIGO "EMBELEZADO", FORMATADO E COMENTADO:
https://github.com/Abnersampf/Simple-Purchasing-Program/blob/main/test.c
00:00 - Apresentação do programa
01:46 - Início do programa
01:55 - Criando as duas Structs
03:01 - Loop que controla o programa
04:07 - Controlando o encerramento do programa
04:17 - Criando o cadastro
10:28 - Criando a listagem
14:09 - Ajustes finais
15:02 - Rodando o programa
16:33 - Fim
Видео PROGRAMA DE CADASTRO EM C - TUTORIAL PASSO A PASSO (2024) канала mPOV
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![TELA AZUL NO PC NOVO - COMO RESOLVER DA MANEIRA MAIS SIMPLES (COMPUTADOR AMD)](https://i.ytimg.com/vi/kH44vYYBVCA/default.jpg)
![COMO PROGRAMAR O JOGO DA COBRA (SNAKE)](https://i.ytimg.com/vi/FIM6FnvcZ6Y/default.jpg)
![GARANTIA DA WESTERN DIGITAL - COMO CRIAR UM RMA](https://i.ytimg.com/vi/xL0DutAnWjQ/default.jpg)
![ENCONTRANDO OS NÚMEROS DE TODAS AS DIAGONAIS DE UMA MATRIZ (C Sharp)](https://i.ytimg.com/vi/wZ3cqGpO6Cs/default.jpg)
![COMO PROGRAMAR EM ASSEMBLY NO WINDOWS](https://i.ytimg.com/vi/3XzPEBX73NI/default.jpg)
![MEU PRIMEIRO PROGRAMA EM 3D](https://i.ytimg.com/vi/seFO_GSJRTc/default.jpg)
![BINÁRIO PARA DECIMAL COM 1 LINHA DE CÓDIGO | E VICE-VERSA (JavaScript)](https://i.ytimg.com/vi/uarChNsDxWI/default.jpg)
![QUAL A MELHOR LINGUAGEM DE PROGRAMAÇÃO PARA INICIANTES ?](https://i.ytimg.com/vi/r_hErpzLug0/default.jpg)
![RESULTADO DO SORTEIO DE UM MINECRAFT ORIGINAL](https://i.ytimg.com/vi/T3nTvAo2yZU/default.jpg)
![GERAR NUMEROS DA MEGA-SENA SEM REPETIR (LINGUAGEM C#)](https://i.ytimg.com/vi/dcQYuIWaCrU/default.jpg)
![SITE COMPLETO FEITO EM PHP PARA VOCÊ USAR COMO PORTFÓLIO NA FACULDADE](https://i.ytimg.com/vi/PYWMEdFCvhs/default.jpg)
![PROBLEMA NA PARTE DAS MOEDAS - URI 1021 COMO RESOLVER + EXPLICAÇÃO (RESOLUÇÃO COM C#)](https://i.ytimg.com/vi/i7QdMr83_Gw/default.jpg)
![AVISO](https://i.ytimg.com/vi/3FYaZFugI-g/default.jpg)
![WAFER PROTEIN DA GROWTH É BOM ? - OPINIÃO SINCERA](https://i.ytimg.com/vi/crSlDt-y9aA/default.jpg)
![VITAMÍNAS TEN TEN (TEN TEN VITAMINS) - REVIEW BRASILEIRO](https://i.ytimg.com/vi/khdTeXpbUpg/default.jpg)
![VISUAL STUDIO OU VISUAL STUDIO CODE - QUAL O MELHOR PARA VOCÊ ?](https://i.ytimg.com/vi/1ClrFzoaPt8/default.jpg)
![COMO OBTER PERMISSÃO DE ADMINISTRADOR MESMO SENDO UM USUÁRIO PADRÃO](https://i.ytimg.com/vi/luGkaPYdjp4/default.jpg)
![CARACTERES ESTRANHOS NO LUGAR DOS ACENTOS - COMO CORRIGIR (Linguagem C)](https://i.ytimg.com/vi/hB6KFP6luL4/default.jpg)
![BRUTE FORCE - COMO FUNCIONA E COMO CRIAR UM PROGRAMA](https://i.ytimg.com/vi/_0GuGyN-L_E/default.jpg)
![COMO BURLAR A PERMISSÃO DE ADMINISTRADOR NO COMPUTADOR DA ESCOLA - MÉTODO ATUALIZADO 2023](https://i.ytimg.com/vi/soKQuMAs02U/default.jpg)