Showing posts with label project work. Show all posts
Showing posts with label project work. Show all posts

Matrix Addition and Mulitplication Is given here

 #include <stdio.h>

#define max 100

int main() {

    int arr1[max][max],arr2[max][max],arr3[max][max],arr4[max][max];

    int k,i,j,n;

    printf("Enter Row and Column of Matrix(both Should be equal to perform the Operation): ");

    scanf("%d",&n);

    printf("Enter Your Array 1 Element\n");

    for(i=0;i<n;i++)

    for(j=0;j<n;j++){

        printf("Enter %d Row %d Column: ",i,j);

        scanf("%d",&arr1[i][j]);

    }

    printf("Enter Your Array 2 Element\n");

    for(i=0;i<n;i++)

    for(j=0;j<n;j++){

        printf("Enter %d Row %d Column: ",i,j);

        scanf("%d",&arr2[i][j]);

    }

    printf("\nYour Matrix 1 is \n");

    for(i=0;i<n;i++){

        for(j=0;j<n;j++){

            printf("%d ",arr1[i][j]);

        }

        printf("\n");

    }

    printf("Your Matrix 2 is \n");

    for(i=0;i<n;i++){

        for(j=0;j<n;j++){

            printf("%d ",arr2[i][j]);

        }

        printf("\n");

    }

    for(i=0;i<n;i++){

        for(j=0;j<n;j++){

            arr3[i][j]+=arr1[i][j]+arr2[i][j];

        }

    }

    printf("\nYour Addition of Matrix is \n");

    for(i=0;i<n;i++){

        for(j=0;j<n;j++){

            printf("%d ",arr3[i][j]);

        }

        printf("\n");

    }

    for(i=0;i<n;i++){

        for(j=0;j<n;j++){

            arr4[i][j]=0;

            for(k=0;k<n;k++)

            arr4[i][j]+=arr1[i][k]*arr2[k][j];

        }

    }

    printf("\nYour mutiplication of Matrix is \n");

    for(i=0;i<n;i++){

        for(j=0;j<n;j++){

            printf("%d ",arr4[i][j]);

        }

        printf("\n");

    }

    


    return 0;

}

ROCK PAPER SCISSOR GAME BUILD USING HTML, CSS and Javascript


 This Rock Paper Scissor Game Build Using HTML CSS and Javascript .

Click Here to View the live website

Click Here to view the original source code at github

Below is the Source Code of Above game

<!--------------------------------- HTML CODE ------------------------->

<!DOCTYPE html>

<html lang="en">

<head>

    <link rel="stylesheet" href="style.css">

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Rockpaperscissor</title>

</head>

<body>

    <div class="container">

        <button class="game" value="Rock">✊</button>

        <button class="game" value="Paper">✋</button>

        <button class="game" value="Scissors">✌</button>

        <div class="showresult">

        <p id="player-score"></p>

        <p id="hands"></p>

        <p id="result"></p>

        </div>

        <button class="reset games" id="endGameButton">🔴</button>

    </div>

    <script src="javascr.js"></script>

    <footer>Made By Vaibhav Yadav with ❤❤</footer>

</body>

</html>

//                                    Javascript Code 

const totalscore = { computerScore: 0, playerScore: 0}


function getcomputerchoice() {

    const rpschoice = ['Rock','Paper','Scissors']

    const randomnumber = Math.floor( Math.random()*3 )

    return rpschoice[randomnumber]

}

function getResult(playerChoice, computerChoice) {

    let score;

    if( playerChoice == computerChoice){ 

    score = 0

    totalscore['computerScore']+= 0

    }

    else if ( playerChoice == 'Rock' && computerChoice == 'Scissors'){

        score = 1

    }

    else if ( playerChoice == 'Paper' && computerChoice == 'Rock'){

        score = 1

    } else if ( playerChoice == 'Scissors' && computerChoice == 'Paper'){

        score = 1

    }

    else{

       score = -1

       totalscore['computerScore']+= 1

 }

    return score

}

function showresult(score,playerChoice,computerChoice)

{

    const resultdiv = document.getElementById('result')

    const handdiv = document.getElementById('hands')

    const playerscorediv = document.getElementById('player-score')

    if(score == -1 ) {

        resultdiv.innerText = "You Lose"

    }

    else if(score == 0 ){

        resultdiv.innerText = "It's a tie"

    }

    else{

        resultdiv.innerText = "You Win"

    }

    handdiv.innerText = "Computer Choice is: " + computerChoice

    playerscorediv.innerText =  "Your Score is : " + totalscore["playerScore"] + "  Computer Score is : " +totalscore["computerScore"]

    

}

function onClickgames(playerChoice){

    // console.log({playerChoice})

    const computerChoice = getcomputerchoice()

    // console.log({computerChoice})

    const score = getResult(playerChoice, computerChoice)

    totalscore['playerScore'] += score

    // console.log({score})

    // console.log(totalscore) 

    showresult(score,playerChoice,computerChoice)

}

function playGame(){

    const games = document.querySelectorAll('.game')

    // games[0].onclick = () => alert(games[0].value)

    

    games.forEach(game => {

        game.onclick = () => onClickgames(game.value)

    })

}

const endgamebutton = document.getElementById("endGameButton")

endgamebutton.onclick = () =>endgame(totalscore)

function endgame(totalscore)

{

    totalscore['playerScore'] = 0

    totalscore['computerScore'] = 0


    const resultdiv = document.getElementById('result')

    const handdiv = document.getElementById('hands')

    const playerscorediv = document.getElementById('player-score')


    resultdiv.innerText = ''

    handdiv.innerText = ''

    playerscorediv.innerText = ''

}

playGame()

/*                              CSS CODE                    */

body{

    background-color: black;

    margin: 0;

    padding: 0;

    font-weight: bolder;

    font-family: sans-serif;

}

.container{

    border-radius: 4%;

    box-shadow: 10px 10px 50px black;

    padding: 2vh;

    width: 80vh;

    text-align: center;

    background-color: steelblue;

    margin: 20vh auto;

}

.container button{

    background-color: transparent;

    border: none;

    

    margin: 3vh;

}

.game {

    box-shadow: 5px 5px 9px black;

    border-radius: 9%;

    /* background-color: red; */

    font-size: 70px;

    cursor: pointer;

}

.reset{

    

    font-size: 50px;

    margin: 9vh 0 0 31vh;

    width: 20vh;

}

/* .container span:hover { 

    transform: rotate(-40deg);

} */

.showresult{

    padding: 2px;

    border-radius: 9px;

    box-shadow: 5px 5px 13px black;

}

.showresultnone{

    height: 0;

    display: none;

}

.games{

    box-shadow: 5px 5px 9px black;

    border-radius: 9%;

    /* background-color: red; */

    font-size: 70px;

    cursor: pointer;

}

button:active{

    transform: translate(2px, 2px);

}

footer{

    text-align: center;

    background-color: wheat;


ROCK PAPER SCISSOR Game using python Language

Below 👇 is the source code for famous ROCK PAPER SCISSOR Game in Python Language.  

Just copy and paste in your Editor and you are ready to go :) 

If you have any query related to this code you are free to ask me, just put your doubt in comment section and I will try to answer it as fast as possible.☺☺

import random, sys

print("----------- Welcome to ROCK-PAPER-SCISSOR Games ------------")

wins = 0 

losses = 0 

tie = 0

while True:

    print("%s wins, %s losses, %s tie" %(wins,losses,tie))

    while True:

        print("Enter Your moves : (r)ock, (s)cissor,(p)aper or (q)uit")

        playerinput = input()

        if(playerinput =='q'):

            sys.exit()

        if playerinput == 'r' or playerinput == 's' or playerinput == 'p':

            break

        print("Type one of r,p,s or q")

        

        

        

    if playerinput == 'r':

        print("ROCK VERSUS...... ")

    elif playerinput == 'p':

        print("PAPER versus......")

    elif playerinput == 's':

        print("SCISSOR versus.....")

        

        #choice of computer starts here :

        

    randomnumber = random.randint(1,3)

    if randomnumber == 1:

        computermove = 'r'

        print("ROCK")

    elif randomnumber == 2:

        computermove = 'p'

        print("PAPER")

    elif randomnumber == 3:

        computermove = 's'

        print("SCISSOR")

        

        #count and display all movees of user and computer

        

    if playerinput == computermove:

        print("It's is a tie ")

        tie+=1

    elif playerinput == 'r' and computermove == 's':

        print("You won")

        wins+=1

    elif playerinput == 'p' and computermove == 'r':

        print("You won")

        wins+=1

    elif playerinput == 's' and computermove == 'p':

        print("You won")

        wins+=1

    else:

        losses +=1

Operator Overloading in C++

#include<iostream> using namespace std; class Complex { private: int real, imag; public: Complex(int r = 0, int i = 0){       re...