diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..c799d123 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +*.exe diff --git a/C/Number-To-Ascii.c b/C/Number-To-Ascii.c new file mode 100644 index 00000000..661b7774 --- /dev/null +++ b/C/Number-To-Ascii.c @@ -0,0 +1,23 @@ +#include + +int main() +{ + int num; + printf("Please insert a number between 0 and 255 [0-255]: "); + scanf("%d",&num); + + if(num >= 0 && num <= 255) + { + + printf("\n The number %d in ASCII is %c \n",num,num); + + } + else{ + + printf("The selected number is not between 0 and 255, please try again. \n"); + + } + + + return 0; +} \ No newline at end of file diff --git a/C/Number-To-Ascii.exe b/C/Number-To-Ascii.exe new file mode 100644 index 00000000..849e7b83 Binary files /dev/null and b/C/Number-To-Ascii.exe differ diff --git a/C/introductionToSWITCH.c b/C/introductionToSWITCH.c new file mode 100644 index 00000000..7c33eae7 --- /dev/null +++ b/C/introductionToSWITCH.c @@ -0,0 +1,53 @@ +// I will be creating a SWITCH script example, a switch can be used instead of if...else statements to optimize the code. + +#include + +int main() +{ + int selectedNum; + printf("Please select a number between [1-10] and it will be printed on the screen."); + scanf("%d",&selectedNum); + + switch (selectedNum) + { + case 1: + printf("The selected number was 1"); + break; + case 2: + printf("The selected number was 2"); + break; + case 3: + printf("The selected number was 3"); + break; + case 4: + printf("The selected number was 4"); + break; + case 5: + printf("The selected number was 5"); + break; + case 6: + printf("The selected number was 6"); + break; + case 7: + printf("The selected number was 7"); + break; + case 8: + printf("The selected number was 8"); + break; + case 9: + printf("The selected number was 9"); + break; + case 10: + printf("The selected number was 10"); + break; + + + default: + printf("The selected number is not between 0 and 10."); + break; + } + +} + + +// another alternative to this script would be checking if selectedNum is bigger or equal to 1 and smaller or equal to 10. \ No newline at end of file diff --git a/DSA/DSA-python/Sorting Algo/BubbleSort.py b/DSA/DSA-python/Sorting Algo/BubbleSort.py index cd5dd192..181af0e9 100644 --- a/DSA/DSA-python/Sorting Algo/BubbleSort.py +++ b/DSA/DSA-python/Sorting Algo/BubbleSort.py @@ -1,20 +1,14 @@ -#this is the most easiest algorith which jst involves swapping of elements -import array -def BubbleSort(a): - n = len(a) - - for i in range(n): - for j in range(i+1 , n): - if(a[i]>a[j]): - a[i] , a[j] = a[j] , a[i] - -a = array.array('i' , []) - -n = int(input("Enter lenght of array : ")) - -for i in range(n): - c = int(input("Enter the number : ")) - a.append(c) - -BubbleSort(a) -print(list(a)) \ No newline at end of file +def bubbleSort(lst): + n = len(lst) + + for i in range(n-1): + + for j in range(0, n-i-1): + + + if lst[j] > lst[j + 1] : + lst[j], lst[j + 1] = lst[j + 1], lst[j] + +lst = [64, 34, 25, 12, 22, 11, 90] + +bubbleSort(lst) diff --git a/DSA/DSA-python/Sorting Algo/BubbleSortt.py b/DSA/DSA-python/Sorting Algo/BubbleSortt.py new file mode 100644 index 00000000..5516eae6 --- /dev/null +++ b/DSA/DSA-python/Sorting Algo/BubbleSortt.py @@ -0,0 +1,20 @@ +#this is the most easiest algorith which jst involves swapping of elements +import array +def BubbleSort(a): + n = len(a) + + for i in range(n): + for j in range(i+1 , n): + if(a[i]>a[j]): + a[i] , a[j] = a[j] , a[i] + +a = array.array('i' , []) + +n = int(input("Enter lenght of array : ")) + +for i in range(n): + c = int(input("Enter the number : ")) + a.append(c) + +BubbleSort(a) +print(list(a)) \ No newline at end of file