Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fa4d780
Program added
Oct 11, 2021
1bd34ff
Add files via upload
sameer2403 Oct 12, 2021
e3c3b0b
Merge pull request #2 from sameer2403/hacktoberfest-2
sameer2403 Oct 12, 2021
419fe76
initial commit
satmm Oct 14, 2021
2b2a596
Merge pull request #335 from Simranverma123/master
swaaz Oct 16, 2021
cbc1f7e
Merge pull request #337 from sameer2403/master
swaaz Oct 16, 2021
20e9641
Merge pull request #342 from satyammmmmm/master
swaaz Oct 16, 2021
01ab4f6
Merge pull request #345 from swaaz/hacktoberfest
swaaz Oct 16, 2021
55bd1ee
Added program to find CSA of cylinder
GowthamPB Oct 16, 2021
c32e6e1
Added a cpp program
Akash2790 Oct 16, 2021
9f775b8
added readme.md
Akash2790 Oct 16, 2021
6f10290
Added program to reverse a given string
GowthamPB Oct 17, 2021
77c1765
Update Readme.md
GowthamPB Oct 17, 2021
c78eb5f
Added program to calculate electricity bill
GowthamPB Oct 17, 2021
f222328
Added program to find discound
GowthamPB Oct 17, 2021
bfb4b67
Added program to calculate batting avg
GowthamPB Oct 17, 2021
c7789e8
Updated readme file
GowthamPB Oct 17, 2021
7af0eba
Merge pull request #346 from GowthamPB/master
swaaz Oct 17, 2021
f66a313
Merge pull request #352 from GowthamPB/Program-18
swaaz Oct 17, 2021
a39789c
Merge pull request #353 from GowthamPB/Program-19
swaaz Oct 17, 2021
a50a757
Merge pull request #355 from GowthamPB/Program-20
swaaz Oct 17, 2021
d977c74
Merge pull request #347 from Akash2790/master
swaaz Oct 19, 2021
0a0c65e
Merge pull request #357 from swaaz/hacktoberfest
swaaz Oct 19, 2021
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
33 changes: 33 additions & 0 deletions C++/Program 29/DecimaltoBinary.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// number to binary number

#include <iostream>
using namespace std;

// function to convert decimal to binary
void decToBinary(int n)
{
// array to store binary number
int binaryNum[32];

// counter for binary array
int i = 0;
while (n > 0) {

// storing remainder in binary array
binaryNum[i] = n % 2;
n = n / 2;
i++;
}

// printing binary array in reverse order
for (int j = i - 1; j >= 0; j--)
cout << binaryNum[j];
}

// Driver program to test above function
int main()
{
int n = 17;
decToBinary(n);
return 0;
}
1 change: 1 addition & 0 deletions C++/Program 29/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C++ program to convert a decimal.
2 changes: 2 additions & 0 deletions C/program-83/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Program 83
Program in C to represent polynomial expression in one variable using linked list.
67 changes: 67 additions & 0 deletions C/program-83/polynomial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include<stdio.h>
#include<stdlib.h>

struct poly
{
int coeff;
int exp;
struct poly *next;
};

void add(struct poly **p,int c,int e) // adding nodes for each order
{
struct poly *new=*p,*temp;
new=(struct poly *)malloc(sizeof(struct poly));
new->coeff=c;
new->exp=e;
new->next=NULL;

if(*p==NULL) // if start is null
*p=new;
else
{
struct poly *temp=*p;
while(temp->next!=NULL)
temp=temp->next;
temp->next=new;
}

}

void display(struct poly **p) // for displaying each node that contains different order of X
{
struct poly*temp=*p;
while(temp!=NULL)
{
printf("+%d",temp->coeff);
if(temp->exp!=0)
printf("x^%d",temp->exp);
temp=temp->next;
}
}

int main()
{
int co,ex;
char ch='y';
struct poly *start=NULL;
printf("Enter the polynomial from highest order to lowest\n");
while(ch=='y')
{
printf("Enter the coefficient of x:\n");
scanf("%d",&co);
printf("enter the exponent of x:\n");
scanf("%d",&ex);
add(&start,co,ex); //calling add function
printf("\n\tDo u want to add more (y/n)");
getchar();
scanf("%c",&ch);

}

printf("\n\tThe polynomial expression is:\t");
display(&start); //final display
printf("\n");
return 0;
}

29 changes: 29 additions & 0 deletions C/program-83/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*program to calculate profit & loss in BITCOIN mining*/

#include<stdio.h>

int main(){

float current_btc_price, avg_cost;
float total_btc, profitloss;

printf("Enter Your Total Bitcoin: ");
scanf("%f",&total_btc);

printf("Enter Current Bitcoin Price: ");
scanf("%f",&current_btc_price);

printf("Your Average Bitcoin Purchase Price: ");
scanf("%f",&avg_cost);

//profitloss = (current_btc_price - averagecost) x total_btc

profitloss = (current_btc_price - avg_cost) * total_btc;

if(profitloss > 0)
printf("Bitcoin Trading Profit is: %0.2f",profitloss);
else
printf("Bitcoin Trading Loss is: %0.2f",profitloss);

return 0;
}
12 changes: 12 additions & 0 deletions Interview Questions/Trapping Rain Water/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Trapping Rain Water


Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.

Input: arr[] = {3, 0, 2, 0, 4}
Output: 7

Explanation:
We can trap "3 units" of water between 3 and 2,
"1 unit" on top of bar 2 and "3 units" between 2
and 4.
63 changes: 63 additions & 0 deletions Interview Questions/Trapping Rain Water/Trapping Rain Water.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// C++ implementation of the approach
#include<bits/stdc++.h>
using namespace std;

int maxWater(int arr[], int n)
{

// indices to traverse the array
int left = 0;
int right = n-1;

// To store Left max and right max
// for two pointers left and right
int l_max = 0;
int r_max = 0;

// To store the total amount
// of rain water trapped
int result = 0;
while (left <= right)
{

// We need check for minimum of left
// and right max for each element
if(r_max <= l_max)
{

// Add the difference between
// current value and right max at index r
result += max(0, r_max-arr[right]);

// Update right max
r_max = max(r_max, arr[right]);

// Update right pointer
right -= 1;
}
else
{

// Add the difference between
// current value and left max at index l
result += max(0, l_max-arr[left]);

// Update left max
l_max = max(l_max, arr[left]);

// Update left pointer
left += 1;
}
}
return result;
}

// Driver code
int main() {
int arr[] = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1};
int n = sizeof(arr)/sizeof(arr[0]);
cout << maxWater(arr, n) << endl;
return 0;
}


Binary file added Java/Program-16/CSAOfCylinder.class
Binary file not shown.
14 changes: 14 additions & 0 deletions Java/Program-16/CSAOfCylinder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.dsa;

import java.util.Scanner;

public class CSAOfCylinder {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter radius and height of cylinder");
float radius=input.nextFloat();
float height=input.nextFloat();
float CSA=2*3.14f*radius*height;
System.out.println("Curved surface area of cylinder is "+CSA+" square units");
}
}
3 changes: 3 additions & 0 deletions Java/Program-16/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Program 16

Program to find CSA of Cylinder
17 changes: 17 additions & 0 deletions Java/Program-17/ReverseString.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.dsa;

import java.util.Scanner;

public class ReverseString {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
String reversed_string="";
System.out.println("Enter the string");
String string= input.next();
for(int i=string.length()-1;i>=0;i--){
reversed_string = reversed_string + string.charAt(i);
}
System.out.println("The original string is "+string);
System.out.println("The reversed string is "+reversed_string);
}
}
3 changes: 3 additions & 0 deletions Java/Program-17/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Program 17

Program to reverse a given string
18 changes: 18 additions & 0 deletions Java/Program-18/ElectricityBill.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//A consumer consumes n watts per hour daily for one month.
// Calculate the total energy bill of that consumer if per-unit rate is 7?
// ( In $, £, €, INR, DHR, Riyal etc.) [Take 1 month = 30 Days].
package com.dsa;

import java.util.Scanner;

public class ElectricityBill {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter the watts consumed per hour");
int watts=input.nextInt();
int electricity=watts*24*30;//Total watts of electricity consumed in 30 days
int cost=(electricity/1000)*7;//We divide by 1000 to convert watts to kilo-watts
//One unit=One kilo-watt and One unit costs 7
System.out.println("The electricity bill is "+cost);
}
}
3 changes: 3 additions & 0 deletions Java/Program-18/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Program-18

Program to calculate electricity bill
17 changes: 17 additions & 0 deletions Java/Program-19/Discount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.dsa;

import java.util.Scanner;

public class Discount {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter the original price of product");
int original_price=input.nextInt();
System.out.println("Enter the discount percentage");
float discount=input.nextInt();
float discount_price=original_price*(discount/100);
float final_price=original_price-discount_price;
System.out.println("The discount price is: "+discount_price);
System.out.println("The final price after discount is: "+final_price);
}
}
3 changes: 3 additions & 0 deletions Java/Program-19/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Program 19

Program to calculate discount
15 changes: 15 additions & 0 deletions Java/Program-20/BattingAverage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.dsa;

import java.util.Scanner;

public class BattingAverage {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter the number of runs scored by the batter");
int runs=input.nextInt();
System.out.println("Enter the number of times the batter got out ");
int out= input.nextInt();
int batting_avg=runs/out;
System.out.println("The batting average of the batter is "+batting_avg);
}
}
3 changes: 3 additions & 0 deletions Java/Program-20/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Program 20

Program to calculate batting average
7 changes: 7 additions & 0 deletions Java/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
| [Program-11](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Java/Program-11/Program.java) | Program for compound interest
| [Program-12](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Java/Program-12/Program-12.java) | Print number of vowels and consonants in a string
| [Program-13](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Java/Program-13/Program%20Number%20to%20Word.java) | Program to convert number into words
| [Program-14](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Java/Program-14/Program%20Number%20to%20Word.java) | Program to convert decimal to binary
| [Program-15](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Java/Program-15/Program%20Number%20to%20Word.java) | Program to convert decimal number to equivalenr binary number
| [Program-16](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Java/Program-16/Program%20Number%20to%20Word.java) | Program to find CSA of cylinder
| [Program-17](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Java/Program-17/Program%20Number%20to%20Word.java) | Program to reverse a given string
| [Program-18](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Java/Program-18/Program%20Number%20to%20Word.java) | Program to calculate electricity bill
| [Program-19](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Java/Program-19/Program%20Number%20to%20Word.java) | Program to calculate discount
| [Program-20](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Java/Program-20/Program%20Number%20to%20Word.java) | Program to calculate batting average

</div>

Expand Down