-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
25 changed files
with
327 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int a[100], i, j, n, low, high, mid, temp, b; | ||
printf("Enter Size of Array: \n"); | ||
scanf("%d", &n); | ||
printf("Enter Elemets in Array \n"); | ||
for (i = 0; i < n; i++) | ||
{ | ||
scanf("%d", &a[i]); | ||
} | ||
low = 0; | ||
high = n - 1; | ||
mid = (low + high) / 2; | ||
for (i = 0; i < n; i++) | ||
{ | ||
if (a[i] > a[i + 1]) | ||
{ | ||
temp = a[i]; | ||
a[i] = a[i + 1]; | ||
a[i + 1] = temp; | ||
} | ||
} | ||
printf("Enter Value to Search: \n"); | ||
scanf("%d", &b); | ||
if (a[mid] == b) | ||
{ | ||
printf("%d is found at %d", b, mid); | ||
} | ||
else | ||
{ | ||
while (low <= high) | ||
{ | ||
if (b < a[mid]) | ||
{ | ||
high = mid - 1; | ||
mid = (low + high) / 2; | ||
if (a[mid] == b) | ||
{ | ||
printf("%d is found at %d \n", b, mid); | ||
} | ||
} | ||
else | ||
{ | ||
low = mid + 1; | ||
mid = (low + high) / 2; | ||
if (a[mid] == b) | ||
{ | ||
printf("%d is found at %d \n", , mid); | ||
} | ||
} | ||
} | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int a[100], i, j, temp, n; | ||
printf("Enter Number of Terms in a Array\n"); | ||
scanf("%d", &n); | ||
printf("Enter Terms in Array\n"); | ||
for (i = 0; i < n; i++) | ||
{ | ||
scanf("%d", &a[i]); | ||
} | ||
printf("Before Sorting, Array A: \n"); | ||
for (i = 0; i < n; i++) | ||
{ | ||
printf("%d ", a[i]); | ||
} | ||
printf("\nPerforming Sorting....\n"); | ||
for (i = 0; i < n; i++) | ||
{ | ||
for (j = 0; j < n - i - 1; j++) | ||
{ | ||
if (a[j] > a[j + 1]) | ||
{ | ||
temp = a[j]; | ||
a[j] = a[j + 1]; | ||
a[j + 1] = temp; | ||
} | ||
} | ||
} | ||
printf("After Sorting, Array A: \n"); | ||
for (i = 0; i < n; i++) | ||
{ | ||
printf("%d ", a[i]); | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int a, b, choice; | ||
printf("Enter First Number\n"); | ||
scanf("%d", &a); | ||
printf("Enter Second Number\n"); | ||
scanf("%d", &b); | ||
printf("Enter 1 for Addition\nEnter 2 for Substraction\nEnter 3 for Multiplication\nEnter 4 for Division\n"); | ||
scanf("%d", &choice); | ||
switch (choice) | ||
{ | ||
case 1: | ||
printf("Addition: %d", a + b); | ||
break; | ||
case 2: | ||
printf("Substraction: %d", a - b); | ||
break; | ||
case 3: | ||
printf("Multiplication: %d", a * b); | ||
break; | ||
case 4: | ||
printf("Quotient: %d", a / b); | ||
break; | ||
default: | ||
printf("Invalid Input!!"); | ||
break; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int a; | ||
printf("Enter Number to find Cube of: \n"); | ||
scanf("%d", &a); | ||
printf("\n Cube of %d is %d", a, a * a * a); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <stdio.h> | ||
int fibonacci(int i) | ||
{ | ||
if (i == 0) | ||
return 0; | ||
else if (i == 1) | ||
return 1; | ||
else | ||
return (fibonacci(i - 1) + fibonacci(i - 2)); | ||
} | ||
int main() | ||
{ | ||
int n; | ||
printf("Enter Number Upto which Fibonacci Series is needed : \n"); | ||
scanf("%d", &n); | ||
printf("Fibonacci Series is: \n"); | ||
for (int i = 0; i < n; i++) | ||
{ | ||
printf("%d", fibonacci(i)); | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include<stdio.h> | ||
int main() | ||
{ | ||
printf("Hello World"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int a[100], n, i, j, temp; | ||
printf("Enter Number of Terms in Array : \n"); | ||
scanf("%d", &n); | ||
printf("Enter Elements in Array\n"); | ||
for (i = 0; i < n; i++) | ||
{ | ||
scanf("%d", &a[i]); | ||
} | ||
printf("Array Before Sorting: \n"); | ||
for (i = 0; i < n; i++) | ||
{ | ||
printf("%d ", a[i]); | ||
} | ||
for (i = 1; i < n-1; i++) | ||
{ | ||
for (j = i + 1; j > 0;j--) | ||
{ | ||
if (a[j] > temp) | ||
{ | ||
a[j + 1] = a[j]; | ||
j--; | ||
} | ||
else | ||
{ | ||
break; | ||
} | ||
} | ||
a[i + 1] = temp; | ||
} | ||
printf("After Sorting: \n"); | ||
for (i = 0; i < n; i++) | ||
{ | ||
printf("%d ", a[i]); | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int a[100][100], b[100][100], c[100][100], i, j, k, r1, r2, c1, c2; | ||
printf("For Matrix A\n"); | ||
printf("Enter Number of Rows in Matrix A\n"); | ||
scanf("%d", &r1); | ||
printf("\nEnter Number of Columns in Matrix A\n"); | ||
scanf("%d", &c1); | ||
printf("Enter Elements in Matrix A\n"); | ||
for (i = 0; i < r1; i++) | ||
{ | ||
for (j = 0; j < c1; j++) | ||
{ | ||
scanf("%d", &a[i][j]); | ||
} | ||
} | ||
printf("\nFor Matrix B\n"); | ||
printf("Enter Number of Rows in Matrix B\n"); | ||
scanf("%d", &r2); | ||
printf("Enter Number of Columns in Matrix B\n"); | ||
scanf("%d", &c2); | ||
printf("Enter Elements in Matrix B\n"); | ||
for (i = 0; i < r2; i++) | ||
{ | ||
for (j = 0; j < c2; j++) | ||
{ | ||
scanf("%d", &b[i][j]); | ||
} | ||
} | ||
if (r2 == c1) | ||
{ | ||
printf("\nPERFORMING MULTIPLICATON\n"); | ||
for (i = 0; j < r1; i++) | ||
{ | ||
for (j = 0; j < c2; j++) | ||
{ | ||
c[i][j] = 0; | ||
} | ||
} | ||
for (i = 0; i < r1; i++) | ||
{ | ||
for (j = 0; j < c2; j++) | ||
{ | ||
for (k = 0; k < r2; k++) | ||
{ | ||
c[i][j] = c[i][j] + (a[i][k] * b[k][j]); | ||
} | ||
} | ||
} | ||
|
||
printf("After Multiplication, Matrix: \n"); | ||
for (i = 0; i < r1; i++) | ||
{ | ||
for (j = 0; j < c2; j++) | ||
{ | ||
printf("%d\t", c[i][j]); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
printf("\nMultiplication can't be Performed, Matrix Doesn't Satisfy the Required Condition"); | ||
} | ||
|
||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int a, b; | ||
printf("Enter Lenght of Rectange\n"); | ||
scanf("%d", &a); | ||
printf("\nEnter Breadth of Rectangle\n"); | ||
scanf("%d", &b); | ||
printf("Perimeter of Rectange is : %d", 2 * (a + b)); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <stdio.h> | ||
int swap(int a, int b) | ||
{ | ||
int temp; | ||
temp = a; | ||
a = b; | ||
b = temp; | ||
printf("After Swapping : A=%d and B=%d", a, b); | ||
} | ||
int main() | ||
{ | ||
int a, b; | ||
printf("Enter First Number : \n"); | ||
scanf("%d", &a); | ||
printf("Enter Second Number : \n"); | ||
scanf("%d", &b); | ||
printf("Before Swapping : A=%d and B=%d \n", a, b); | ||
swap(a, b); | ||
|
||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include<stdio.h> | ||
int main() | ||
{ | ||
int a,b,temp; | ||
printf("Enter First Number: \n"); | ||
scanf("%d",&a); | ||
printf("Enyter Second Number:\n"); | ||
scanf("%d",&b); | ||
printf("Before Swapping A=%d and B=%d \n",a,b); | ||
printf("PERFORMING SWAPPING"); | ||
temp=a; | ||
a=b; | ||
b=temp; | ||
printf("After Swapping A=%d and B=%d",a,b); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int a, b; | ||
printf("Enter First Number : \n"); | ||
scanf("%d", &a); | ||
printf("Enter Second Number :"); | ||
scanf("%d", &b); | ||
printf("Before Swapping A=%d and B=%d \n", a, b); | ||
a = a + b; | ||
b = a - b; | ||
a = a - b; | ||
printf("After Swapping A=%d and B=%d", a, b); | ||
return 0; | ||
} |
Binary file not shown.