Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ratnesh1dwivedi authored Jul 16, 2024
1 parent 9978371 commit d8c7922
Show file tree
Hide file tree
Showing 100 changed files with 2,646 additions and 0 deletions.
29 changes: 29 additions & 0 deletions C++/bankbalanceass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
using namespace std;

int main() {
double balance = 0.0;

cout << "Enter your initial account balance: $";
cin >> balance;

double withdrawAmount, depositAmount;

cout << "Enter the amount you want to withdraw: $";
cin >> withdrawAmount;

if (withdrawAmount > balance) {
cout << "Insufficient balance for withdrawal." << endl;
} else {
balance -= withdrawAmount;
cout << "Amount withdrawn. New balance: $" << balance << endl;
}

cout << "Enter the amount you want to deposit: $";
cin >> depositAmount;

balance += depositAmount;
cout << "Amount deposited. New balance: $" << balance << endl;

return 0;
}
39 changes: 39 additions & 0 deletions C++/drinkingmachineass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <iostream>
using namespace std;

int main() {
const double COKE_PRICE = 1.25;
const double PEPSI_PRICE = 1.50;
const double WATER_PRICE = 0.75;

double amountPaid;
int choice;

cout << "Welcome to the Drink Vending Machine!" << endl;
cout << "1. Coke ($" << COKE_PRICE << ")" << endl;
cout << "2. Pepsi ($" << PEPSI_PRICE << ")" << endl;
cout << "3. Water ($" << WATER_PRICE << ")" << endl;

cout << "Enter your choice (1/2/3): ";
cin >> choice;

if (choice == 1) {
cout << "You selected Coke. Please enter the amount you're paying: $";
cin >> amountPaid;

if (amountPaid >= COKE_PRICE) {
double change = amountPaid - COKE_PRICE;
cout << "Enjoy your Coke! Your change: $" << change << endl;
} else {
cout << "Insufficient funds. Please insert more money." << endl;
}
} else if (choice == 2) {
// Similar logic for Pepsi
} else if (choice == 3) {
// Similar logic for Water
} else {
cout << "Invalid choice. Please select 1, 2, or 3." << endl;
}

return 0;
}
40 changes: 40 additions & 0 deletions C++/mimiccalculatorass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>
using namespace std;

int main() {
int num1, num2;
char operation;

cout << "Enter first integer: ";
cin >> num1;

cout << "Enter second integer: ";
cin >> num2;

cout << "Enter operation (+, -, *, /): ";
cin >> operation;

switch (operation) {
case '+':
cout << num1 << " + " << num2 << " = " << num1 + num2 << endl;
break;
case '-':
cout << num1 << " - " << num2 << " = " << num1 - num2 << endl;
break;
case '*':
cout << num1 << " * " << num2 << " = " << num1 * num2 << endl;
break;
case '/':
if (num2 != 0) {
cout << num1 << " / " << num2 << " = " << static_cast<double>(num1) / num2 << endl;
} else {
cout << "Error: Division by zero is not allowed." << endl;
}
break;
default:
cout << "Invalid operation." << endl;
break;
}

return 0;
}
26 changes: 26 additions & 0 deletions C++/palindromeass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>

int main() {
int originalNumber, reversedNumber = 0, remainder, temp;

std::cout << "Enter a five-digit integer: ";
std::cin >> originalNumber;

temp = originalNumber; // Store the original number in a temporary variable

// Reversing the number
while (temp > 0) {
remainder = temp % 10;
reversedNumber = reversedNumber * 10 + remainder;
temp /= 10;
}

// Checking if the reversed number is equal to the original number
if (reversedNumber == originalNumber) {
std::cout << originalNumber << " is a palindrome." << std::endl;
} else {
std::cout << originalNumber << " is not a palindrome." << std::endl;
}

return 0;
}
27 changes: 27 additions & 0 deletions C++/recursionass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
using namespace std;

// Recursive function to calculate factorial
unsigned long long factorial(int n) {
if (n == 0 || n == 1) {
return 1;
} else {
return n * factorial(n - 1);
}
}

int main() {
int num;

cout << "Enter a positive integer: ";
cin >> num;

if (num < 0) {
cout << "Factorial is not defined for negative numbers." << endl;
} else {
unsigned long long result = factorial(num);
cout << "Factorial of " << num << " is " << result << endl;
}

return 0;
}
25 changes: 25 additions & 0 deletions C++/righttriangleass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
using namespace std;

int main() {
double side1, side2, side3;

cout << "Enter the lengths of three sides of the triangle:" << endl;
cout << "Side 1: ";
cin >> side1;
cout << "Side 2: ";
cin >> side2;
cout << "Side 3: ";
cin >> side3;

// Check the Pythagorean theorem
if (side1 * side1 + side2 * side2 == side3 * side3 ||
side2 * side2 + side3 * side3 == side1 * side1 ||
side1 * side1 + side3 * side3 == side2 * side2) {
cout << "The triangle with sides " << side1 << ", " << side2 << ", and " << side3 << " is a right triangle." << endl;
} else {
cout << "The triangle with sides " << side1 << ", " << side2 << ", and " << side3 << " is not a right triangle." << endl;
}

return 0;
}
28 changes: 28 additions & 0 deletions C++/topscoreass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
const int NUM_SCORES = 5; // Number of scores
vector<double> scores(NUM_SCORES);

cout << "Enter " << NUM_SCORES << " scores:" << endl;
for (int i = 0; i < NUM_SCORES; ++i) {
cout << "Score " << i + 1 << ": ";
cin >> scores[i];
}

// Sort the scores in descending order
sort(scores.begin(), scores.end(), greater<double>());

double sumTop4 = 0.0;
for (int i = 0; i < 4; ++i) {
sumTop4 += scores[i];
}

double averageTop4 = sumTop4 / 4.0;
cout << "Average of the top 4 scores: " << averageTop4 << endl;

return 0;
}
13 changes: 13 additions & 0 deletions C/ALPHABET.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Program to find the alphabet

#include<stdio.h>
#include<conio.h>
void main()
{char c;
printf("Enter the Character:");
scanf("%c",&c);
if ((c>='a' && c<='z') || (c>='A' && c<='Z'))
{printf("It's an Alphabet");}
else
{printf("It's not an Alphabet");}
getch();}
13 changes: 13 additions & 0 deletions C/ANGLETRI.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Program for checking the Triangle

#include<stdio.h>
#include<conio.h>
void main()
{int a1,a2,a3;
printf("Enter three Angles of Triangle:\n");
scanf("%d %d %d" ,&a1,&a2,&a3);
if (a1+a2+a3==180)
{printf("It's a valid Triangle");}
else
{printf("It's not a Triangle");}
getch();}
15 changes: 15 additions & 0 deletions C/CHTYPE.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//Program to check character type

#include<stdio.h>
#include<conio.h>
void main()
{char c;
printf("Enter a Character:");
scanf("%c",&c);
if ((c>='a' && c<='z')||(c>='A' && c<='Z'))
{printf("It's an Alphabet");}
else if (c>='0' && c<='9')
{printf("It's a Number");}
else
{printf("It's a Special Character ");}
getch();}
13 changes: 13 additions & 0 deletions C/COUNTMAC.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Program for Cash Counting Machine

#include<stdio.h>
#include<conio.h>
void main()
{int a,b,c;
printf("Enter which type of notes you have:");
scanf("%d",&a);
printf("Enter amount of money:");
scanf("%d",&b);
c=b/a;
printf("%d notes are there",c);
getch();}
17 changes: 17 additions & 0 deletions C/DAYMONO.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Program for checking the Days in a month

#include<stdio.h>
#include<conio.h>
void main()
{int x;
printf("Enter the number of month:");
scanf("%d",&x);
if(x==1||x==3||x==5||x==7||x==8||x==10||x==12)
{printf("This month has 31 Days");}
else if (x==4||x==6||x==9||x==11)
{printf("This month has 30 Days");}
else if(x==2)
{printf("The month has 29 Days ");}
else
{printf("Invalid Entry");}
getch();}
26 changes: 26 additions & 0 deletions C/DAYNAME.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//Program to find starting day

#include<stdio.h>
#include<conio.h>
void main()
{ int num;
{printf("Note-Day 1 Start with Sunday");}
printf("\nEnter the Day Number:");
scanf("%d",&num);
if(num==1)
{printf("Day is Sunday");}
else if(num==2)
{printf("Day is Monday");}
else if(num==3)
{printf("Day is Tuesday");}
else if (num==4)
{printf("Day is Wednesday");}
else if (num==5)
{printf("Day is Thursday");}
else if (num==6)
{printf("Day is Friday");}
else if (num==7)
{printf("Day is Saturday");}
else
{printf("Entry is Invalid");}
getch();}
21 changes: 21 additions & 0 deletions C/EBILL.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//Electricity Bill Generator

#include<stdio.h>
#include<conio.h>
void main()
{int unit;
float amt,total_amt,sur_charge;
printf("Enter total units consumed:");
scanf("%d",&unit);
if (unit<=50)
{amt= unit*0.50;}
else if (unit<=150)
{amt=25+((unit-50)*0.75);}
else if (unit<=250)
{amt=100+((unit-150)*1.20);}
else
{amt=200+((unit-250)*1.50);}
sur_charge=amt*0.20;
total_amt=amt+sur_charge;
printf("Electricity Bill=Rs%2f",total_amt);
getch();}
20 changes: 20 additions & 0 deletions C/EIGHT.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// program to print prime numbers to n

#include<stdio.h>
#include<conio.h>
void main()
{int n,j,i,count;
clrscr();
printf("Enter the limit:");
scanf("%d",&n);
printf("Prime numbers till %d:",n);
for(i=1;i<=n;i++)
{count=0;
for (j=1;j<=i;j++)
{if (i%j==0)
{count++;}

else
{printf("%d",i);}
}}
getch();}
16 changes: 16 additions & 0 deletions C/ERRORCAS.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Program to find Lowecase OR Uppercase

#include<stdio.h>
#include<conio.h>
void main()
char ch;
{clrscr();
printf("Enter the Character:");
scanf("%c",&ch);
if (ch>='A' && ch<='Z')
{printf("The Character is Uppercase");}
else if (ch>='a' && ch<='z')
{printf("The character is Lowercase");}
else
{printf("It's not an Alphabet");}
getch();}
Loading

0 comments on commit d8c7922

Please sign in to comment.