Codes

1. Multiples of 3 or 7

Change the logic to print numbers that are multiples of 3 or 7 instead of 5 or 6.

// Inside process_file, replace the if condition:
if (val != 0 && (val % 3 == 0 || val % 7 == 0)) {
    printf("%d\n", val);
}

2. Multiples of 30 (5 AND 6)

Modify the program to only print numbers that are both multiples of 5 AND 6.

// Inside process_file:
if (val != 0 && (val % 5 == 0 && val % 6 == 0)) {
    printf("%d\n", val);
}

3. Custom Separators

Update the separator string to include custom characters like @, #, or $.

// Inside process_file:
char *separators = " -\r\t\n./,@#$";

4. Match Counter

Instead of printing the numbers, print the total count of how many matches were found in the file.

5. Standard Input Support

Modify sixfive to read from standard input (0) if no filename argument is provided.

6. Range Filter (10-100)

Implement a range filter to only print matching numbers that fall between 10 and 100.

7. Hexadecimal Output

Change the output format to print all identified numbers in hexadecimal.

8. Exclude Number 6

Modify the code so that it never prints the number 6, even if it is a multiple of 6.

9. Sum Summary

Add a summary at the end of the output that prints the total sum of all numbers found.

10. Filename Header

Update the program to print the filename on the first line before listing the numbers found.

Last updated