Skip to content
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

Main #59

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Main #59

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
20 changes: 20 additions & 0 deletions Bubblesort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<stdio.h>
int main()
{
int a[10],i,j,temp;
{
printf("Enter\n");
scanf("%d",&a[i]);
}
printf("array is:\n");
for(i=0;i<10;i++)
printf("%d",a[i]);
for(i=0;i<10;i++)
for(j=0;j<a[i];j++)
{
if(a[i]>a[j]+1)
{
temp=a[j];
}
}
}
22 changes: 22 additions & 0 deletions Factorial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<stdio.h>

int factorial(int number)
{
if(number==1 ||number ==0 )
{
return 1;
}
else
{
return(number*factorial(number-1));
}
}
int main()
{
int num;
printf("Enter a number\n");
scanf("%d",&num);
printf("The factorial of %d is %d\n",num,factorial(num));
return 0;

}
17 changes: 17 additions & 0 deletions Letter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>

int main()
{
char str[100];
printf("Enter a string\n");
fgets(str, sizeof(str), stdin);
for (int i = 0; str[i]!='\0'; i++)
{
if ( (str[i]) && (i == 0 || (str[i - 1])))
{
printf("%c",str[i]);
}
}
printf("\n");
return 0;
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Mentorship-2024
# Mentorship-2024
20 changes: 20 additions & 0 deletions Sonavdeep Sharma/Bubblesort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<stdio.h>
int main()
{
int a[10],i,j,temp;
{
printf("Enter\n");
scanf("%d",&a[i]);
}
printf("array is:\n");
for(i=0;i<10;i++)
printf("%d",a[i]);
for(i=0;i<10;i++)
for(j=0;j<a[i];j++)
{
if(a[i]>a[j]+1)
{
temp=a[j];
}
}
}
22 changes: 22 additions & 0 deletions Sonavdeep Sharma/Factorial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<stdio.h>

int factorial(int number)
{
if(number==1 ||number ==0 )
{
return 1;
}
else
{
return(number*factorial(number-1));
}
}
int main()
{
int num;
printf("Enter a number\n");
scanf("%d",&num);
printf("The factorial of %d is %d\n",num,factorial(num));
return 0;

}
17 changes: 17 additions & 0 deletions Sonavdeep Sharma/Letter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>

int main()
{
char str[100];
printf("Enter a string\n");
fgets(str, sizeof(str), stdin);
for (int i = 0; str[i]!='\0'; i++)
{
if ( (str[i]) && (i == 0 || (str[i - 1])))
{
printf("%c",str[i]);
}
}
printf("\n");
return 0;
}
2 changes: 2 additions & 0 deletions Sonavdeep Sharma/Sonav.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hello
It's Sonav here
24 changes: 24 additions & 0 deletions Sonavdeep Sharma/determinant.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<stdio.h>

int main()
{
int a[2][2], i, j;
long determinant;
printf("Enter the 4 elements of the array\n");
for(i = 0; i < 2; i++)
for(j = 0; j < 2; j++)
scanf("%d", &a[i][j]);
printf("\nThe entered matrix is: \n");
for(i = 0; i < 2; i++)
{
for(j = 0; j < 2; j++)
{
printf("%d", a[i][j]);
}
printf("\n");
}
determinant = a[0][0]*a[1][1] - a[1][0]*a[0][1];
printf("\nDterminant of 2x2 matrix is : %ld - %ld = %ld", a[0][0]*a[1][1], a[1][0]*a[0][1], determinant);

return 0;
}
30 changes: 30 additions & 0 deletions Sonavdeep Sharma/palindrome.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>
#include<string.h>

int main()
{
char string1[20];
int i, length;
int temp = 0;
printf("Enter a string: ");
scanf("%s", string1);
length = strlen(string1);

for (i = 0; i < length / 2; i++) {
if (string1[i] != string1[length - i - 1])
{
temp = 1;
break;
}
}

if (temp)
{
printf("%s is not a palindrome\n", string1);
} else {
printf("%s is a palindrome\n", string1);
}

return 0;
}

24 changes: 24 additions & 0 deletions determinant.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<stdio.h>

int main()
{
int a[2][2], i, j;
long determinant;
printf("Enter the 4 elements of the array\n");
for(i = 0; i < 2; i++)
for(j = 0; j < 2; j++)
scanf("%d", &a[i][j]);
printf("\nThe entered matrix is: \n");
for(i = 0; i < 2; i++)
{
for(j = 0; j < 2; j++)
{
printf("%d", a[i][j]);
}
printf("\n");
}
determinant = a[0][0]*a[1][1] - a[1][0]*a[0][1];
printf("\nDterminant of 2x2 matrix is : %ld - %ld = %ld", a[0][0]*a[1][1], a[1][0]*a[0][1], determinant);

return 0;
}
30 changes: 30 additions & 0 deletions palindrome.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>
#include<string.h>

int main()
{
char string1[20];
int i, length;
int temp = 0;
printf("Enter a string: ");
scanf("%s", string1);
length = strlen(string1);

for (i = 0; i < length / 2; i++) {
if (string1[i] != string1[length - i - 1])
{
temp = 1;
break;
}
}

if (temp)
{
printf("%s is not a palindrome\n", string1);
} else {
printf("%s is a palindrome\n", string1);
}

return 0;
}