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
82 changes: 82 additions & 0 deletions C++/Program_25/Queues_Using_Linked_Lists.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//Queues Using Linked List
#include<iostream>
using namespace std;

class node{
public:
int data;
node *link;
}*front=NULL,*rear=NULL;

void enqueue(int x){
node *t;
t = new node;
if(t==NULL)
cout<<"Queue is Full"<<endl;
else{
t->data = x;
t->link = NULL;
}
if(front==NULL){
front = rear = t;
}
else{
rear->link=t;
rear = t;
}
}

int dequeue(){
node *p;
int x = -1;
if(front==NULL)
cout<<"Queue is Empty!"<<endl;
else{
front = p->link;
x = p->data;
delete p;
}
return x;
}

void display(){
node *p=front;
while(p){
cout<<p->data<<" ";
p = p->link;
}
cout<<endl;
}

int main(){
int x;
char c;
while(1){
cout<<"Choose an Operation : \n1.Enqueue\n2.Dequeue\n3.Display\n4.Exit"<<endl;
cin>>c;
switch (c)
{
case '1':
cout<<"Enter the element : ";
cin>>x;
enqueue(x);
break;
case '2':
x=dequeue();
if(x!=-1)
cout<<"Deleted element is "<<x<<endl;
break;
case '3':
display();
break;
case '4':
return 0;
break;
default:
cout<<"Enter a valid option :("<<endl;
break;
}
}

return 0;
}
1 change: 1 addition & 0 deletions C++/Program_25/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Program to implement Queue DataStructure Using Linked Lists
1 change: 1 addition & 0 deletions C++/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
| Program-15 | Program to find modular exponentiation.
| Program-19| To check whether a number is in palindrome or not
| Program-24 | Program to convert Hexa-Decimal number to Decimal number
| Program-25 | Program to Implement Queue Data Structure Using Linked Lists
42 changes: 42 additions & 0 deletions C/program-61/program.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
//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;


/*
This Program calulates all the prime between the range of numbers
includes the numbers which is provided.
Expand Down
15 changes: 15 additions & 0 deletions C/program-74/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include<stdio.h>
int main()
{
int n, reverse=0, rem;
printf("Enter a number: ");
scanf("%d", &n);
while(n!=0)
{
rem=n%10;
reverse=reverse*10+rem;
n/=10;
}
printf("Reversed Number: %d",reverse);
return 0;
}
1 change: 1 addition & 0 deletions C/program-74/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C Program to reverse a given number
51 changes: 51 additions & 0 deletions C/program-77/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <stdio.h>

int main()
{
int m, n, p, q, c, d, k, sum = 0;
int mat1[10][10], mat2[10][10], mat3[10][10];

printf(“Enter number of rows and columns of mat1 matrix\n”);
scanf(“%d%d”, &m, &n);
printf(“Enter elements of matrix 1\n”);

for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
scanf(“%d”, &mat1[c][d]);

printf(“\nEnter number of rows and columns of mat2 matrix\n”);
scanf(“%d%d”, &p, &q);

if (n != p)
printf(“\nThe matrices can’t be multiplied with each other.\n”);
else
{
printf(“\nEnter elements of matrix2\n”);

for (c = 0; c < p; c++)
for (d = 0; d < q; d++)
scanf(“%d”, &mat2[c][d]);

for (c = 0; c < m; c++) {
for (d = 0; d < q; d++) {
for (k = 0; k < p; k++) {
sum = sum + mat1[c][k]*mat2[k][d];
}

mat3[c][d] = sum;
sum = 0;
}
}

printf(“\nProduct of the matrices:\n”);

for (c = 0; c < m; c++) {
for (d = 0; d < q; d++)
printf(“%d\t”, mat3[c][d]);

printf(“\n”);
}
}

return 0;
}
1 change: 1 addition & 0 deletions C/program-77/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C program to multiply matrices
24 changes: 24 additions & 0 deletions C/program-78/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<stdio.h>

int main()
{
printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
int h, b;
float area;
printf("\n\nEnter the height of the Triangle: ");
scanf("%d", &h);
printf("\n\nEnter the base of the Triangle: ");
scanf("%d", &b);

/*
Formula for the area of the triangle = (height x base)/2

Also, typecasting denominator from int to float
to get the output in float
*/
area = (h*b)/(float)2;
printf("\n\n\nThe area of the triangle is: %f", area);

printf("\n\n\t\t\tCoding is Fun !\n\n\n");
return 0;
}
1 change: 1 addition & 0 deletions C/program-78/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C Program to find the Area of Triangle using Base and Height
22 changes: 22 additions & 0 deletions C/program-79/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<stdio.h>

void main()
{
printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
float principal_amt, rate, simple_interest;
int time;
printf("Enter the value of principal amount, rate and time\n\n\n");
scanf("%f%f%d", &principal_amt, &rate, &time);

// considering rate is in percentage
simple_interest = (principal_amt*rate*time)/100.0;

// usually used to align text in form of columns in table
printf("\n\n\t\t\tAmount = Rs.%7.3f\n ", principal_amt);

printf("\n\n\t\t\tRate = Rs.%7.3f\n ", rate);
printf("\n\n\t\t\tTime= %d years \n", time);
printf("\n\n\t\t\tSimple Interest = Rs.%7.3f\n ", simple_interest);
printf("\n\n\t\t\tCoding is Fun !\n\n\n");
return 0;
}
1 change: 1 addition & 0 deletions C/program-79/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C Program to calculate Simple Interest
60 changes: 60 additions & 0 deletions Java/program-3/program.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
//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;
}

}


import java.io.*;
import java.util.*;
class Prg{
Expand Down
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()