-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 62252a1
Showing
7 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/.vscode | ||
/Task_1.exe | ||
/Task_2.exe | ||
/Task_4.exe | ||
/Task_5.exe | ||
/Task_8.exe | ||
/Task_9.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Calculator which can perform basic Arithmetic Operations like addtion,Substraction,Multiplication & Division | ||
|
||
#include<iostream> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
float num1,num2; | ||
char op; | ||
|
||
cout<<"Enter two numbers to perform arithmatic operations : "; | ||
cin>>num1>>num2; | ||
cout<<endl; | ||
cout<<"Enter operation to be performed (+,-,*,/) : "; | ||
cin>>op; | ||
cout<<endl; | ||
|
||
cout<<num1<<" "<<op<<" "<<num2<<" = "; | ||
|
||
switch(op) | ||
{ | ||
// Addition | ||
case '+': | ||
cout<<num1+num2; | ||
break; | ||
|
||
// Subtraction | ||
case '-': | ||
cout<<num1-num2; | ||
break; | ||
|
||
// Multiplication | ||
case '*': | ||
cout<<num1*num2; | ||
break; | ||
|
||
case '/': | ||
if(num2!=0) | ||
{ | ||
cout<<num1/num2; | ||
|
||
} | ||
else { | ||
cout<<"Undefined"; | ||
} | ||
break; | ||
|
||
default: | ||
cout<<"Error ! Operator not Defined"; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Generate a random number between a range [Low,High] | ||
|
||
#include<iostream> | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int n,i=1,number; | ||
|
||
int high; | ||
int low; | ||
cin>>low>>high; | ||
|
||
cout<<"Lower Limit and Higher limit are : "<<low<< " and "<<high<<endl; | ||
// using srand() for generating a different number for each time | ||
srand(time(0)); | ||
|
||
// Now generating a random number | ||
number=rand()%(high-low+1)+1; | ||
|
||
|
||
cout<<"Guess a number between high and low case : "; | ||
|
||
do { | ||
|
||
cin>>n; | ||
|
||
if(number ==n) | ||
{ | ||
cout<<"Congrats you have guessed right number which is "<<number<<endl; | ||
cout<<"Number of turns you have used "<<i; | ||
i++; | ||
break; | ||
} | ||
|
||
else if(number>n){ | ||
cout<<"Low!! Enter a higher number than previous , Number of turns you used is "<<i<<endl; | ||
i++; | ||
} | ||
else{ | ||
cout<<"High ! Enter a lower number than previous ,Number of turns you have used is "<<i<<endl; | ||
i++; | ||
} | ||
}while(number!=n); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// sum of two results after rolling two dices | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
srand(time(0)); // to generate a different random number each time | ||
int Result1=rand()%6+1; // first number after rolling dice1 between [1,6] | ||
|
||
int Result2=rand()%6+1; // second number after rolling dice2 between [1,6] | ||
|
||
cout<<"Result After rolling first Dice : "<<Result1<<endl; | ||
cout<<"Result After rolling second Dice : "<<Result2<<endl; | ||
|
||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Temprature Convertor between Celsius and Fahrenheit | ||
|
||
#include<iostream> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
float Tempratue ; | ||
|
||
cout<<"EnterTemprature : "; | ||
cin>>Tempratue; | ||
|
||
|
||
char Unit ; | ||
cout<<"Enter Unit of Temprature (Celsius/Fahrenheit) : "; | ||
cin>>Unit; | ||
cout<<endl; | ||
|
||
cout<<"Temprature "<<Unit<<"is : "<<Tempratue<<" ( "<<Unit<<" ) "<<endl; | ||
|
||
switch(Unit) | ||
{ | ||
case 'C': | ||
cout<<"Tempreture in Fahrenheit is : "<< ((9.0/5.0)*Tempratue+32.0); | ||
break; | ||
|
||
case 'F': | ||
cout<<"Temprature in Celsius is : "; | ||
cout<< (Tempratue-32.0)*(5.0/9.0); | ||
break; | ||
|
||
default: | ||
cout<<"You have Entered undefined conversion unit "; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include<iostream> | ||
using namespace std; | ||
|
||
void BinaryToDecimal( int binary) | ||
{ | ||
int b=binary; | ||
int ans=0; | ||
while(b!=0) | ||
{ | ||
int p=1; | ||
int r=b%10; | ||
//int d=0; | ||
ans+=r*p; | ||
p*=2; | ||
b/=10; | ||
|
||
} | ||
cout<<binary<<"="<<ans; | ||
} | ||
int main() | ||
{ | ||
int b; | ||
cin>>b; | ||
BinaryToDecimal(b); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// A program to generate a random password of userdefined length | ||
|
||
#include <iostream> | ||
#include<cstdlib> | ||
#include<ctime> | ||
using namespace std; | ||
const char Domain[] = "0123456789!@#$%^&*abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
int length = sizeof(Domain)-1;// length of our domain string | ||
int main() | ||
{ | ||
int n; // length of our password | ||
cout<<"Enter the length of password:"; | ||
cin>>n; | ||
srand(time(0)); //to generate new character every time | ||
|
||
if(n==0) // if no length is given | ||
{ | ||
cout<<"Please enter a minimum length of password ,it can't be empty !!!"; | ||
} | ||
else{ | ||
cout<<"Your password is : "; | ||
for(int i = 0; i < n; i++) | ||
cout << Domain[rand() % length]; // rand() to generate a random character from our domain character array | ||
} | ||
return 0; | ||
} |