Skip to content
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"C_Cpp.default.compilerPath": "/bin/gcc"
}
Binary file added __pycache__/matplotlib.cpython-312.pyc
Binary file not shown.
Binary file added a.out
Binary file not shown.
23 changes: 13 additions & 10 deletions issue1.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
// Make sure the function reverse actually reverses the string
// Made sure the function reverse actually reverses the string

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char* reverse(char* str){
char* rev = (char*)malloc(sizeof(str));
char *reverse(char *str)
{
char *rev = (char *)malloc(sizeof(str));
int size = strlen(str);
for(int i=0;i<size;i++){
rev[i] = str[i];
for (int i = 0; i < size; i++)
{
rev[size - i - 1] = str[i];
}
return rev;
}

int main(){
char* str = "Forward";
int main()
{
char *str = "Forward";
str = reverse(str);
printf("%s\n", str);
}
10 changes: 6 additions & 4 deletions issue2.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Make sure program prints all even numbers from 1 to 40
// Made sure program prints all even numbers from 1 to 40

#include <stdio.h>

int main(){
int main()
{
int even = 0;
for(int i = 0; i <= 20; i++){
even *= 2;
for (int i = 1; i <= 20; i++)
{
even += 2;
printf("%d\t", even);
}
printf("\n");
Expand Down
16 changes: 9 additions & 7 deletions issue3.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
// Make sure the program prints the string correctly
// Made sure the program prints the string correctly

#include <stdio.h>

int main(){
int main()
{
// Printing all the characters in an array
char z[] = {'h', 'e', 'l', 'l', 'o', '!'};

char new[50] = "";
char new[50] = "";

for(int i = 0; i < 6; i++){
new[i] = z;
for (int i = 0; i < 6; i++)
{
new[i] = z[i];
}

for(int i = 0; i < 6; i++){
for (int i = 0; i < 6; i++)
{
printf("%c", new[i]);
}
printf("\n");
return 0;

}
24 changes: 15 additions & 9 deletions issue4.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// Make sure the sorting algorithm is correct
// Made sure the sorting algorithm is correct

#include <stdio.h>

void sort(int a[], int b){
for(int i = 0; i < b; i++){
for(int j = 1; j < b; j++){
if(a[i] > a[j]){
void ascending_sort(int a[], int b)
{
for (int i = 0; i < b; i++)
{
for (int j = i; j < b; j++)
{
if (a[i] > a[j])
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
Expand All @@ -14,12 +18,14 @@ void sort(int a[], int b){
}
}

int main(){
int main()
{
// Sort in ascending order
int numbers[] = {4, 2, 3, 1, 8, 7};
sort(numbers, 6);

for(int i = 0; i < 6; i++){
ascending_sort(numbers, 6);

for (int i = 0; i < 6; i++)
{
printf("%d", numbers[i]);
}
}
54 changes: 32 additions & 22 deletions issue5.c
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
// Make sure you only get the desired output
// Made sure you only get the desired output

#include<stdio.h>
int main(void){
#include <stdio.h>
int main(void)
{
int flag = 0;

printf("Choose the operation:-\n1. Multiples of 2\n2. Multiples of 3\n3. Multiples of 4\n");
scanf(" %d", &flag);

switch(flag){
case 1 :
for(int i=1;i<6;i++){
printf("%d\t", 2*i);
}
printf("\n");
case 2 :
for(int i=1;i<6;i++){
printf("%d\t", 3*i);
}
printf("\n");
case 3 :
for(int i=1;i<6;i++){
printf("%d\t", 4*i);
}
printf("\n");
default :
printf("Choose a valid option!!!\n");
switch (flag)
{
case 1:
for (int i = 1; i < 6; i++)
{
printf("%d\t", 2 * i);
}
printf("\n");
break;
case 2:
for (int i = 1; i < 6; i++)
{
printf("%d\t", 3 * i);
}
printf("\n");
break;
case 3:
for (int i = 1; i < 6; i++)
{
printf("%d\t", 4 * i);
}
printf("\n");
break;

default:
printf("Choose a valid option!!!\n");
break;
}
}
15 changes: 8 additions & 7 deletions issue6.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Make sure the program is working correct logically
// Made sure the program is working correct logically

#include<stdio.h>
#include<string.h>
int main(void){
char* str1 = "This is a string";
char* str2 = "This is another string";
#include <stdio.h>
#include <string.h>
int main(void)
{
char *str1 = "This is a string";
char *str2 = "This is another string";

if(strcmp(str1, str2))
if (!strcmp(str1, str2))
printf("Strings are same.\n");
else
printf("Strings are not same.\n");
Expand Down
13 changes: 7 additions & 6 deletions issue7.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Make sure the output is the correct sum of a and b
// Made sure the output is the correct sum of a and b

#include<stdio.h>
#include<stdlib.h>
#include <stdio.h>
#include <stdlib.h>

int main(void){
int main(void)
{
int a = 5;
int* b = (int*)malloc(sizeof(int));
int *b = (int *)malloc(sizeof(int));
*b = 7;
printf("%d\n", (a+b));
printf("%d\n", (a + *b));
}
16 changes: 9 additions & 7 deletions issue8.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Only print the given string, nothing more
// Bonus if you don't count the number of characters in the string manually
// Only printed the given string, nothing more
// didn't count the number of characters in the string manually

#include<stdio.h>
#include<string.h>
int main(void){
char* str = "Welcome to IEEE\n";
for(int i=0;i<100;i++){
#include <stdio.h>
#include <string.h>
int main(void)
{
char *str = "Welcome to IEEE\n";
for (int i = 0; i < strlen(str) - 1; i++)
{
printf("%c", str[i]);
}
printf("\n");
Expand Down
4 changes: 2 additions & 2 deletions issue9.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// print correct factorial of the variable "num"
// printed correct factorial of the variable "num"

#include<stdio.h>
int factorial(int n){
if(n == 2)
if(n == 1)
return 1;
else
return n*factorial(n-1);
Expand Down
3 changes: 3 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
all:
g++ ncurses.cpp -lncurses
./a.out
9 changes: 9 additions & 0 deletions matplotlib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import matplotlib.pyplot as pt

x=[1,2,3,4,5,6,7]
y=[1,2,3,4,5,6,7]

pt.plot(x,y)
pt.xlable("x")
pt.ylable("y")
pt.show()
53 changes: 53 additions & 0 deletions ncurses.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <ncurses.h>


int main()
{
// initating a terminal window
initscr();
// to start reciveing input immideateliy but on by default
cbreak();
// to pritnt to window
printw("hello world");
printw("enter the pin:");
// to hide the keystrokes
noecho();
for (int i = 0; i < 4; i++)
{
getch();
}
// to show the keystrokes
echo();

int height = 10, width = 20, start_y = 1, start_x = 1;

// created a window
WINDOW *win = newwin(height, width, start_y, start_x);
//to refresh the window
refresh();

//to add border to created sub window
box(win, 0, 0);
mvwprintw(win, 1, 1, "frame 1");
wrefresh(win);


// getting environment info
int y, x, ybeg, xbeg, ymax, xmax;
getyx(stdscr, y, x);
getmaxyx(stdscr, ymax, xmax);
getbegyx(win, ybeg, xbeg);

move(10, 10);
box(win, 10, 10);

wrefresh(win);

printw("%d %d %d %d %d %d", y, x, ybeg, xbeg, ymax, xmax);
wrefresh(win);
getch();

endwin();

return 0;
}
24 changes: 24 additions & 0 deletions proc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#! /bin/bash

# showinf uptime
a=($(cat /proc/uptime))
h=$( echo "${a[0]}/3600" | bc )
min=$(echo "((${a[0]}%3600)/60)" | bc )

echo "uptime: $h hr and $min min"

# showing load average
l=($(cat /proc/loadavg))
echo "loadavg"
for num in {0..2}
do
c=$( echo "${l[num]}*100" | bc )

echo " $c % "
done
echo " running processes/total : ${l[3]} "
echo " most recent process (ID) : ${l[4]} "




Loading