Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

Low_level_programming

low_level_programming – 0x01-variables_if_else_while part 2

8-print_base16.c

#include <stdio.h>

/**
 * main - Prints all the numbers of base 16 in lowercase.
 *
 * Return: Always 0.
 */
int main(void)
{
	int num;
	char letter;

	for (num = 0; num < 10; num++)
		putchar((num % 10) + '0');

	for (letter = 'a'; letter <= 'f'; letter++)
		putchar(letter);

	putchar('\n');

	return (0);
}

9-print_comb.c

#include <stdio.h>

/**
 * main - Prints all possible combinations of single-digit numbers.
 *
 * Return: Always 0.
 */
int main(void)
{
	int num;

	for (num = 0; num <= 9; num++)
	{
		putchar((num % 10) + '0');
		if (num == 9)
			continue;

		putchar(',');
		putchar(' ');
	}

	putchar('\n');

	return (0);
}

100-print_comb3.c

#include <stdio.h>

/**
 * main - Prints all possible combinations of two different digits,
 *        in ascending order, separated by a comma followed by a space.
 *
 * Return: Always 0.
 */
int main(void)
{
	int digit1, digit2;

	for (digit1 = 0; digit1 < 9; digit1++)
	{
		for (digit2 = digit1 + 1; digit2 < 10; digit2++)
		{
			putchar((digit1 % 10) + '0');
			putchar((digit2 % 10) + '0');

			if (digit1 == 8 && digit2 == 9)
				continue;
			putchar(',');
			putchar(' ');
		}
	}

	putchar('\n');

	return (0);
}

101-print_comb4.c

#include <stdio.h>

/**
 * main - Prints all possible combinations of three different digits
 * in ascending order, separated by a comma followed by a space.
 *
 * Return: Always 0.
 */
int main(void)
{
	int digit1, digit2, digit3;

	for (digit1 = 0; digit1 < 8; digit1++)
	{
		for (digit2 = digit1 + 1; digit2 < 9; digit2++)
		{
			for (digit3 = digit2 + 1; digit3 < 10; digit3++)
			{
				putchar((digit1 % 10) + '0');
				putchar((digit2 % 10) + '0');
				putchar((digit3 % 10) + '0');

				if (digit1 == 7 && digit2 == 8 && digit3 == 9)
					continue;

				putchar(',');
				putchar(' ');
			}
		}
	}

	putchar('\n');

	return (0);
}

102-print_comb5.c

#include <stdio.h>

/**
 * main - Prints all possible combinations of two two-digit numbers,
 * ranging from 0-99, separated by a comma followed by a space.
 *
 * Return: Always 0.
 */
int main(void)
{
	int num1, num2;

	for (num1 = 0; num1 <= 98; num1++)
	{
		for (num2 = num1 + 1; num2 <= 99; num2++)
		{
			putchar((num1 / 10) + '0');
			putchar((num1 % 10) + '0');
			putchar(' ');
			putchar((num2 / 10) + '0');
			putchar((num2 % 10) + '0');

			if (num1 == 98 && num2 == 99)
				continue;

			putchar(',');
			putchar(' ');
		}
	}

	putchar('\n');

	return (0);
}

README.md

Create a readme.md file with

 echo 'whatever you want to use to describe your work' > README.md

See part1: low_level_programming – 0x01-variables_if_else_while

Show some love by sharing.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
Low_level_programming

low_level_programming – 0x01-variables_if_else_while part 1

Next Post
Welcome-to-Canada

Temporary Foreign Workers Jobs in Canada 2022/2023 – Apply Now

Please Leave a comment on comment section, let me know what you think about this article.

Related Posts
Low_level_programming

alxlow_level_programming/0x02-functions_nested_loops/

Table of Contents Hide 0x02-functions_nested_loopsRequirements_putchar.c main.h0-putchar.c1-alphabet.c 2-print_alphabet_x10.c 3-islower.c 4-isalpha.c 5-sign.c6-abs.c7-print_last_digit.c8-24_hours.c9-times_table.c10-add.c 11-print_to_98.c100-times_table.c 101-natural.c102-fibonacci.c 103-fibonacci.c104-fibonacci.c README.md 0x02-functions_nested_loops Requirements Allowed editors: vi, vim, emacs…
Read More
Hey, if you have any questions and want to talk to one of our specialists chat up here:
Chat me up