Skip to content

Add 2 C Projects + optimize Python Script #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.exe
23 changes: 23 additions & 0 deletions C/Number-To-Ascii.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>

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;
}
Binary file added C/Number-To-Ascii.exe
Binary file not shown.
53 changes: 53 additions & 0 deletions C/introductionToSWITCH.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>

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.
34 changes: 14 additions & 20 deletions DSA/DSA-python/Sorting Algo/BubbleSort.py
Original file line number Diff line number Diff line change
@@ -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))
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)
20 changes: 20 additions & 0 deletions DSA/DSA-python/Sorting Algo/BubbleSortt.py
Original file line number Diff line number Diff line change
@@ -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))