Thursday, December 24, 2020

Arrays in cpp with Eaglesoft

 


#include<iostream>
using namespace std;
int main()
{
    int num[4000],limit;
    cout<<"Enter size of array less than 4000:"<<endl;
    cin>>limit;
    if(limit>4000)
    {
        cout<<"Please Enter size of array less than 4000"<<endl;
    }
    else
    {
        for(int i=0;i<limit;i++)
        {
            cout<<"Enter you "<<i+1<<" Value :"<<endl;
            cin>>num[i];
        }
        for(int i=0;i<limit;i++)
        {
            cout<<"Enter value of "<<i+1<<" :"<<num[i]<<endl;
        }
    }

    cout<<"***Eaglesoft Programmers***"<<endl;
    return 0;
}

Wednesday, December 23, 2020

Arrays and Pointers in c++ | cpp with Eaglesoft

 


#include<iostream>
using namespace std;
int main()
{
    int num[100],limit;
    cout<<"Enter array limit: "<<endl;
    cin>>limit;
    int *p;
    p=num;
    for (int i = 0; i < limit; i++)
    {
        cout<<"Enter value of of a["<<i<<"] :"<<endl;
        cin>>num[i];
    }
    for (int i = 0; i < limit; i++)
    {
        cout<<"Value of a["<<i<<"] :"<<*p++<<endl;
    }
    
    cout<<"******Eaglesoft Porgrammers******"<<endl;
    return 0;
}

Monday, December 21, 2020

Sum of two array in cpp with Eaglesoft programmers


#include<iostream>
using namespace std;
int main()
{
    int a[20][20],b[20][20],sum[20][20],r,c;
    cout<<"Enter number of rows for arry :"<<endl;
    cin>>r;
    cout<<"Enter number of colums for arry :"<<endl;
    cin>>c;

    // input in table A 
    for(int i=0; i<r; i++)
    {
        for(int j=0; j<c; j++)
        {
            cout<<"Enter value of a"<<i+1<<j+1<<endl;
            cin>>a[i][j];
        }
    }
    // input in table B 
    for(int i=0; i<r; i++)
    {
        for(int j=0;j<c;j++)
        {
            cout<<"Enter Value of b"<<i+1<<j+1<<endl;
            cin>>b[i][j];
        }
    }
    
    // Add table A and B 
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            sum[i][j]=a[i][j]+b[i][j];
        }
    }

    // Show Output
    for(int i=0; i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            cout<<"Sum of a"<<i<<j<<"+ b"<<i<<j<<" :"<<sum[i][j]<<endl;
        }
    }

    return 0;

} 

Monday, December 14, 2020

Get Search result in Python

 


def matchingWords(sentence1, sentence2):
    words1 = sentence1.strip().split(" ")
    words2 = sentence2.strip().split(" ")
    score = 0
    for word1 in words1:
        for word2 in words2:
            # print(f"Matchin word {word1} with {word2} ")
            if word1.lower() == word2.lower():
                score += 1
    return score


if __name__ == "__main__":
    # print(matchingWords("This is a good", "Python is a good"))
    sentences = ["Ashfaq is good boy",
                 "He work for Eaglesoft", "Eaglesoft is on of the best"]
    query = input("Please enter your query:\n")
    scores = [matchingWords(query, sentece) for sentece in sentences]
    # print(scores)
    sortSentScore = [sentScore for sentScore in sorted(
        zip(scores, sentences), reverse=True) if sentScore[0] != 0]
    # print(sortSentScore)
    print(f"{len(sortSentScore)} results found!\n")
    for score, item in sortSentScore:
        print(f" \"{item}\" with the score of {score}")

Sunday, December 13, 2020

Number guess game in Python with Eaglesoft Programmers

 


import random


def guessGame(a, b, num_random):
    guess = int(input(f"Guess a number between {a} to {b}:\n"))
    nguess = 1
    while guess != num_random:
        if guess < num_random:
            guess=int(input("Enter bigger!\n"))
            nguess += 1
        else:
            guess=int(input("Enter less!\n"))
            nguess += 1
    print(f"You guess the number in {nguess} attempt\n")
    return nguess


if __name__ == "__main__":
    a = int(input("Enter the value A"))
    b = int(input("Enter the value B"))
    num_random1 = random.randint(a, b)
    print("Player 1's is turn")
    g1 = guessGame(a, b, num_random1)
    print("Player 2's is turn")
    num_random2 = random.randint(a, b)
    g2 = guessGame(a, b, num_random2)
    if g1 < g2:
        print("Player 1 win!\n")
    elif g1 > g2:
        print("Player 2 win!\n")
    else:
        print("Tie!")
    print(f"Player 1 number is {num_random1} and Player 2 number is {num_random2} !\n")

Saturday, December 12, 2020

Find next palindrome in Python with Eaglesoft Programmers.


def next_palindrome(n):
    n=n+1
    while not is_palindrome(n):
        n += 1
    return n

def is_palindrome(n):
    return str(n)==str(n)[::-1]

if __name__ == "__main__":
    n=int(input("Enter the number of casese\n"))
    numbers=[]
    for i in range(n):
        number=int(input("Enter the number of that you want to find next palindrom\n"))
        numbers.append(number)

    for i in range(n):
        print(f"Next palindrome of {numbers[i]} is {next_palindrome(numbers[i])}")
    

Wednesday, December 2, 2020

Find divisor in python with Eaglesoft Programmers

 


n=int(input("Enter a number of apples:"))
mn=int(input("Enter minimum number:"))
mx=int(input("Enter maximum number"))
for i in range(mn,mx+1):
    if n%i==0:
        print(f"{i} is a divisor of {n}")
    else:
        print(f"{i} is not a divisor of {n}")


print("***This is Eaglesoft Programmer***")