Skip to content

Commit

Permalink
formatting source-code for 5bba04b
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and github-actions committed Jun 28, 2020
1 parent 5bba04b commit 6f98288
Show file tree
Hide file tree
Showing 134 changed files with 440 additions and 623 deletions.
2 changes: 1 addition & 1 deletion client_server/udp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int main()
memset(&cliaddr, 0, sizeof(cliaddr));

// Filling server information
servaddr.sin_family = AF_INET; // IPv4
servaddr.sin_family = AF_INET; // IPv4
servaddr.sin_addr.s_addr = INADDR_ANY;
servaddr.sin_port = htons(PORT);

Expand Down
4 changes: 1 addition & 3 deletions conversions/binary_to_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@

int main()
{

int remainder, number = 0, decimal_number = 0, temp = 1;
printf("/n Enter any binary number= ");
scanf("%d", &number);

// Iterate over the number until the end.
while (number > 0)
{

remainder = number % 10;
number = number / 10;
decimal_number += remainder * temp;
temp = temp * 2; // used as power of 2
temp = temp * 2; // used as power of 2
}

printf("%d\n", decimal_number);
Expand Down
4 changes: 2 additions & 2 deletions conversions/binary_to_octal.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int main(void)
while (binary_num > 0)
{
if (binary_num >
111) // Checking if binary number is greater than three digits
111) // Checking if binary number is greater than three digits
td = three_digits(binary_num);

else
Expand All @@ -45,7 +45,7 @@ int main(void)
base *= 2;
}

res += d * ord; // Calculating the octal value
res += d * ord; // Calculating the octal value
ord *= 10;
}

Expand Down
2 changes: 0 additions & 2 deletions conversions/decimal_to_binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

int main()
{

// input of the user
int inputNumber;

Expand Down Expand Up @@ -35,7 +34,6 @@ int main()
// actual processing
while (inputNumber > 0)
{

// computes the remainder by modulo 2
re = inputNumber % 2;

Expand Down
3 changes: 0 additions & 3 deletions conversions/decimal_to_hexa.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ void decimal2Hexadecimal(long num);

int main()
{

long decimalnum;

printf("Enter decimal number: ");
Expand All @@ -19,7 +18,6 @@ int main()
* number****************/
void decimal2Hexadecimal(long num)
{

long decimalnum = num;
long quotient, remainder;
int i, j = 0;
Expand All @@ -29,7 +27,6 @@ void decimal2Hexadecimal(long num)

while (quotient != 0)
{

remainder = quotient % 16;
if (remainder < 10)
hexadecimalnum[j++] = 48 + remainder;
Expand Down
5 changes: 1 addition & 4 deletions conversions/decimal_to_octal.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ void decimal2Octal(long decimalnum);

int main()
{

long decimalnum;

printf("Enter the decimal number: ");
Expand All @@ -30,9 +29,7 @@ void decimal2Octal(long decimalnum)
quotient = quotient / 8;
}

for (j = i - 1; j > 0; j--)

printf("%d", octalNumber[j]);
for (j = i - 1; j > 0; j--) printf("%d", octalNumber[j]);

printf("\n");
}
3 changes: 0 additions & 3 deletions conversions/octal_to_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ int convertValue(int num, int i) { return num * pow(8, i); }

long long toDecimal(int octal_value)
{

int decimal_value = 0, i = 0;

while (octal_value)
{

// Extracts right-most digit and then multiplies by 8^i
decimal_value += convertValue(octal_value % 10, i++);

Expand All @@ -24,7 +22,6 @@ long long toDecimal(int octal_value)

int main()
{

printf("Enter octal value: ");

int octal_value;
Expand Down
10 changes: 5 additions & 5 deletions data_structures/array/carray_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
*
*/

#include "CArray.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "CArray.h"

int CArrayTests()
{
Expand All @@ -37,7 +37,7 @@ int CArrayTests()
}
printf("Entered array is:\n");
displayCArray(array);
printf("\nCode: %d\n", pushValueCArray(array, 11)); // 5
printf("\nCode: %d\n", pushValueCArray(array, 11)); // 5

for (i = 0; i < array->size; i++)
{
Expand All @@ -46,16 +46,16 @@ int CArrayTests()

displayCArray(array);

printf("\nCode: %d", removeValueCArray(array, -1)); // 1
printf("\nCode: %d\n", insertValueCArray(array, -1, 1)); // 1
printf("\nCode: %d", removeValueCArray(array, -1)); // 1
printf("\nCode: %d\n", insertValueCArray(array, -1, 1)); // 1

// Erase
for (i = 0; i < array->size; i++)
{
insertValueCArray(array, i, i + 1);
}
eraseCArray(array);
displayCArray(array); // Should give all 0s
displayCArray(array); // Should give all 0s

// Switching
CArray *arr = getCArray(13);
Expand Down
8 changes: 2 additions & 6 deletions data_structures/binary_trees/avl.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ avlNode *minNode(avlNode *node)
{
avlNode *temp = node;

while (temp->left != NULL)
temp = temp->left;
while (temp->left != NULL) temp = temp->left;

return temp;
}
Expand All @@ -64,8 +63,7 @@ void printAVL(avlNode *node, int level)
printAVL(node->right, level + 1);
printf("\n\n");

for (i = 0; i < level; i++)
printf("\t");
for (i = 0; i < level; i++) printf("\t");

printf("%d", node->key);

Expand Down Expand Up @@ -117,7 +115,6 @@ avlNode *RightLeftRotate(avlNode *z)

avlNode *insert(avlNode *node, int key)
{

if (node == NULL)
return (newNode(key));

Expand Down Expand Up @@ -310,7 +307,6 @@ int main()

case 1:
{

printf("\n\tEnter the Number to insert: ");
scanf("%d", &insertNum);

Expand Down
11 changes: 4 additions & 7 deletions data_structures/binary_trees/binary_search_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// Node, the basic data structure in the tree
typedef struct node
{

// left child
struct node *left;

Expand All @@ -27,7 +26,6 @@ typedef struct node
// pointer
node *newNode(int data)
{

// creates a slug
node *tmp = (node *)malloc(sizeof(node));

Expand Down Expand Up @@ -110,7 +108,6 @@ node *delete (node *root, int data)
// subtree and switch with the root's
else
{

// finds the biggest node in the left branch.
node *tmp = getMax(root->left);

Expand Down Expand Up @@ -190,7 +187,6 @@ void inOrder(node *root)

void main()
{

// this reference don't change.
// only the tree changes.
node *root = NULL;
Expand All @@ -200,9 +196,10 @@ void main()
// event-loop.
while (opt != 0)
{
printf("\n\n[1] Insert Node\n[2] Delete Node\n[3] Find a Node\n[4] Get "
"current Height\n[5] Print Tree in Crescent Order\n[0] Quit\n");
scanf("%d", &opt); // reads the choice of the user
printf(
"\n\n[1] Insert Node\n[2] Delete Node\n[3] Find a Node\n[4] Get "
"current Height\n[5] Print Tree in Crescent Order\n[0] Quit\n");
scanf("%d", &opt); // reads the choice of the user

// processes the choice
switch (opt)
Expand Down
6 changes: 3 additions & 3 deletions data_structures/binary_trees/recursive_traversals.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

void inOrderTraversal(struct node *node)
{
if (node == NULL) // if tree is empty
if (node == NULL) // if tree is empty
return;

inOrderTraversal(node->leftNode);
Expand All @@ -17,7 +17,7 @@ void inOrderTraversal(struct node *node)

void preOrderTraversal(struct node *node)
{
if (node == NULL) // if tree is empty
if (node == NULL) // if tree is empty
return;

printf("\t%d\t", node->data);
Expand All @@ -27,7 +27,7 @@ void preOrderTraversal(struct node *node)

void postOrderTraversal(struct node *node)
{
if (node == NULL) // if tree is empty
if (node == NULL) // if tree is empty
return;

postOrderTraversal(node->leftNode);
Expand Down
Loading

0 comments on commit 6f98288

Please sign in to comment.