Skip to content
Merged
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
41 changes: 41 additions & 0 deletions C/program-61/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//C Program For Bubble Sort In Ascending And Descending Order//

#include<stdio.h>

int main()
{

int array[100], n, c, d, swap;

printf("Enter number of elements\n");
scanf("%d", &n);

printf("Enter %d integers\n", n);

for (c = 0; c < n; c++)
scanf("%d", &array[c]);

for (c = 0 ; c < ( n - 1 ); c++)
{
for (d = 0 ; d < n - c - 1; d++)
{
if (array[d] > array[d+1])
{
swap = array[d];
array[d] = array[d+1];
array[d+1] = swap;
}
}
}

printf("Sorted list in ascending order:\n");

for ( c = 0 ; c < n ; c++ )
printf("%d\n", array[c]);

printf("\nSorted list in descending order:\n");

for ( c = n-1 ; c >= 0; c-- )
printf("%d\n", array[c]);
return 0;
}
58 changes: 58 additions & 0 deletions Java/program-3/program.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//Java Program to Find Transpose of a Matrix//






import java.util.Arrays;

public class Matrix {

// main method
public static void main(String[] args) {

// declare and initialize a matrix
int a[][] = { { 1, 2 }, { 8, 9 } };

// find row and column size
int row = a.length;
int column = a[0].length;

// declare new matrix to store result
int transpose[][] = new int[row][column];

// Transpose of matrix
transpose = transposeMatrix(a);

// display all matrices
System.out.println("A = " + Arrays.deepToString(a));
System.out.println("Transpose = " +
Arrays.deepToString(transpose));
}

// method to calculate the transpose of a matrix
public static int[][] transposeMatrix(int[][] a) {

// calculate row and column size
int row = a.length;
int column = a[0].length;

// declare a matrix to store resultant
int temp[][] = new int[row][column];

// calculate transpose of matrix
// outer loop for row
for (int i = 0; i < row; i++) {
// inner loop for column
for (int j = 0; j < column; j++) {
// formula
temp[i][j] = a[j][i];
}
}

// return resultant matrix
return temp;
}

}
17 changes: 17 additions & 0 deletions Javascript/program-7/program.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// program to sort words in alphabetical order

// take input
const string = prompt('Enter a sentence: ');

// converting to an array
const words = string.split(' ');

// sort the array elements
words.sort();

// display the sorted words
console.log('The sorted words are:');

for (const element of words) {
console.log(element);
}
10 changes: 10 additions & 0 deletions Python/program-5/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rows = int(input("Enter Same Number Rows & Columns Square Pattern Rows = "))

print("===Printing Same Number in Rows and Columns of a Square Pattern===")

for i in range(1, rows + 1):
for j in range(i, rows + 1):
print(j, end = ' ')
for k in range(1, i):
print(k, end = ' ')
print()