Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void main(){
- int input = 1;
- int errors = 0;
- int runCount = 0;
- int input1 = 0, input2 = 0;
- int isPerfect = 0, isGerman = 0, isLowerPair = 0, isPrime = 0, isPalindrome = 0;
- int sum = 0;
- int i, j;
- while (input != 0 && errors < 5){
- sum = 0;
- isPerfect = isGerman = isLowerPair = isPrime = isPalindrome = 0;
- if (input == 1 || input == 2){
- printf("The menu:\n 0. Exit.\n 1. Print menu again.\n 2. Number details in range.\n 3. Layers square printing.\n Please enter your choice:\n");
- scanf("%d", &input);
- if (input == 1){
- } else if (input == 2){
- printf("Please enter the first int positive number (up to 8 digits):\n");
- scanf("%d", input1);
- while (input1 < 1 || input1 > 99999999){
- printf("Please enter the first int positive number (up to 8 digits):\n");
- scanf("%d", input1);
- }
- while (input2 < input1 + 10 && input2 > input1 + 150){
- printf("Please enter the 2nd positive number between %d and %d:\n", input1 + 10, input1 + 150);
- scanf("%d", input2);
- }
- for (i = input1; i <= input2; i++){
- for (j = 1; j < i; j++){
- if (i % j == 0){
- sum += j;
- }
- }
- isGerman = 1;
- for (j = 2; j < 2 * i + 1; j++){
- if (i % j == 0){
- isGerman = 0;
- break;
- }
- }
- isPrime = 1;
- for (j = 2; j < i; j++){
- if (i % j == 0){
- isPrime = 0;
- break;
- }
- }
- isLowerPair = 1;
- if (isPrime){
- for (j = 2; j < i - 2; j++){
- if ((i - 2) % j == 0){
- isLowerPair = 0;
- break;
- }
- }
- }
- }
- } else {
- errors++;
- }
- }
- else if (input != 0 && errors < 5){
- printf("Wrong input. please try again (enter 1 for re-printing the menu) :\n");
- scanf("%d", &input);
- if (input != 1 && input != 2){
- errors++;
- }
- }
- }
- printf("bye bye !!\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement