From 1b06c6ce0d3cb9218f2e9c6123346f37b28d5180 Mon Sep 17 00:00:00 2001 From: Nireeksha Date: Tue, 5 Oct 2021 22:31:53 +0530 Subject: [PATCH 1/4] comment --- C/program-61/program.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 C/program-61/program.c diff --git a/C/program-61/program.c b/C/program-61/program.c new file mode 100644 index 00000000..f0b55ed4 --- /dev/null +++ b/C/program-61/program.c @@ -0,0 +1,41 @@ +//C Program For Bubble Sort In Ascending And Descending Order// + +#include + +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; +} \ No newline at end of file From 226939b222f88de0b4dd698a0d7be82efaaa7a5f Mon Sep 17 00:00:00 2001 From: Nireeksha Date: Tue, 5 Oct 2021 22:54:54 +0530 Subject: [PATCH 2/4] program added --- Python/program-5/program.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Python/program-5/program.py diff --git a/Python/program-5/program.py b/Python/program-5/program.py new file mode 100644 index 00000000..0b2242ab --- /dev/null +++ b/Python/program-5/program.py @@ -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() \ No newline at end of file From 491abba43169e08460b6b2c0025eb3517988703f Mon Sep 17 00:00:00 2001 From: Nireeksha Date: Tue, 5 Oct 2021 23:07:52 +0530 Subject: [PATCH 3/4] program added --- Java/program-3/program.java | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Java/program-3/program.java diff --git a/Java/program-3/program.java b/Java/program-3/program.java new file mode 100644 index 00000000..5a5c9233 --- /dev/null +++ b/Java/program-3/program.java @@ -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; + } + +} \ No newline at end of file From fafa0bcd48774e359ae0474c91a3c508a711975c Mon Sep 17 00:00:00 2001 From: Nireeksha Date: Tue, 5 Oct 2021 23:14:41 +0530 Subject: [PATCH 4/4] program added --- Javascript/program-7/program.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Javascript/program-7/program.js diff --git a/Javascript/program-7/program.js b/Javascript/program-7/program.js new file mode 100644 index 00000000..ee78770a --- /dev/null +++ b/Javascript/program-7/program.js @@ -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); +} \ No newline at end of file