Skip to content

Instantly share code, notes, and snippets.

@vtvh
Created August 15, 2023 03:19
Show Gist options
  • Save vtvh/40e4acc3f27194436b763a8c1bbbf027 to your computer and use it in GitHub Desktop.
Save vtvh/40e4acc3f27194436b763a8c1bbbf027 to your computer and use it in GitHub Desktop.
// De Thi 1
// 15.08.2023
#include <stdio.h>
#include <stdlib.h>
void doQuestionR1()
{
int n, evenDivisor = 0;
printf("Input an integer: ");
scanf("%d", &n);
printf("All the devisors of k:");
for (int i = 1; i <= n; i++)
{
if (n % i == 0)
{
if (i % 2 == 0)
evenDivisor++;
printf("%d ", i);
}
}
printf("\n Number of even divisors: %d \n", evenDivisor);
return;
}
void doQuestionR2()
{
struct CannedMilk
{
char label[30];
int weight[4]{100, 200, 300, 400};
double price;
};
return;
}
void doQuestionR3()
{
puts("Exit program....");
exit(0);
}
void menu()
{
puts("*********************************");
puts("* Select Action: ");
puts("* \t 1. R1");
puts("* \t 2. R2");
puts("* \t 3. R3");
puts("*********************************");
}
int main()
{
int choice;
do
{
menu();
printf("Option: ");
scanf("%d", &choice);
// Choice into programs:
switch (choice)
{
case 1:
doQuestionR1();
break;
case 2:
doQuestionR2();
break;
case 3:
doQuestionR3();
break;
default:
// clear screen
printf("\033[H\033[2J");
puts("\n\t INVALID! Please choose from 1 2 or 3.");
continue;
}
} while (1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment