Sunday, December 27, 2020

Summation of two array elements by using two different class in OPP(C++)

#include<iostream>
using namespace std;
class C1{
private:
        int sum1 = 0;
public:
        void inp1(int A[], int s1){
                for(int i = 0; i < s1; i++){
                        sum1 = sum1 + A[i];
                }
        }
        friend class C2;
};
class C2{
private:
        int sum2 = 0;
public:
        void inp2(int B[], int s2){
                for(int i = 0; i < s2; i++){
                        sum2 = sum2 + B[i];
                }
        }
        void sum(C1 &obj){
                int S = obj.sum1;
                int res = S + sum2;
                cout<<"Summation of two array elements: "<<res<<endl;
        }
};
int main()
{
        int arr1[] = {2, 3, 4, 5, 6, 7};
        int arr2[] = {20, 30, 40};
        C1 obj1;
        obj1.inp1(arr1, 6);
        C2 obj2;
        obj2.inp2(arr2, 3);
        obj2.sum(obj1);
        return 0;
}

Saturday, November 28, 2020

Encapsulation implementation in c++ with bank example

#include<iostream>//Encapsulation in OOP with C++ Language
using namespace std;
class bank{//Class Declaration
private:
         double balance;//Data Member
public://Access Specifier
        void setValue(double b)//Member Function
        {
                balance = b;
        }
        void show(){////Member Function
                cout<<balance<<endl;
        }
};
int main()
{
        bank obj;
        obj.setValue(1000.50);
        obj.show();
        return 0;
}
Youtube link: https://www.youtube.com/watch?v=o7z06_HlSI8&list=PLhGaMw0JdiTKfgMpw6xI1Dh_2RYyPKszj&index=16

Friday, November 27, 2020

Data abstraction in c++ example with header file abstraction and specifier abstraction

//Data Abstraction Using Access Specifiers
#include<iostream>
#include<math.h>
using namespace std;
class abstract{//Class Declaration
private://Private Access Specifier
        int num1, num2;//Data Members
public://Public Access Specifier
        void setValue(int a, int b){//Member Function
                num1 = a;
                num2 = b;
        }
        void display()//Member Function
        {
                cout<<num1<<" "<<num2<<endl;
        }
};
int main()//Main Function
{
        abstract obj;//Object creation
        obj.setValue(10, 20);//Function Calling
        obj.display();//Function Calling

        int res = pow(4, 3);
        cout<<res<<endl;
        return 0;
}

Monday, November 16, 2020

C programming output checking-05 || Recursion function example with prop...


IT job preparation. Bank job preparation. Govt. it job preparation Output checking of c program. Recursion function with proper description in c/cpp. How does the recursion function work? Recursion in c programming with two parameters.

Sunday, November 15, 2020

C programming output checking-04 || IT job preparation || Infinite Loop ...


Govt. it job preparation Output checking of a c program. Running a loop for infinite time when the condition is not true.

C programming output checking-02 || IT job preparation || Floor and ceil...


Output checking of a c program.
Finding floor and ceil value of a negative number in c.
C program to find the floor value of a number.
C program to find the ceil value of a number.
C program output checking for finding floor and ceil value.

C programming output checking-02 || IT job preparation || Function calli...


#best_programming_solution
#it_job_preparation
#output_of_c_program
#Alamgir_Hossain
IT job preparation.
Bank job preparation.
Govt. it job preparation
Output checking of c program.
Calling a function by the call by value.
Situation when the swap function is not working in c/cpp.
C program output checking using the swap function.

C programming output checking-01 || IT job preparation || Programming in...


#best_programming_solution
#it_job_preparation
#output_of_c_program
#Alamgir_Hossain
IT job preparation.
Bank job preparation.
Govt. it job preparation
Output checking of c program
What is the output of the given c program??

Saturday, November 14, 2020

তাওহীদি প্রেরণার অবমাননা -আলমগীর হোসেন

 

তাওহীদি প্রেরণার অবমাননা

-আলমগীর হোসেন

 

 

মানবতার মুক্তির দূত

রাহমাতুল্লিল আলামিন

যার আগমনে আত্মহারা সব, বিয়োগে স্তব্ধতা

যাকে উপেক্ষায়

বিশ্ব মুসলিম হৃদয় রক্তাক্ত, চারিদিকে চঞ্চলতা ।।

 

ওরা ভুলেছে

নিদারুণ পরিণতি ।

যারা করেছিলো নিন্দা, দিয়েছিলো গালি

নিকৃষ্টতায় ছিন্নভিন্ন হয়েছে

ওদের সকল অস্থি, সম্পত্তি ।।

 

জাগো আবারও মুসলিম

দুনিয়ার মুসলমান ।

রাসুলকে(সাঃ) দিয়েছে অবজ্ঞা, করেছে অপমান

                তুমি এখনও জীবিত

তোমার দেহে প্রাণ, শিরায় রক্ত বহমান ।।

 

নহে ব্যাঙ্গ-বিদ্রুপ

ওহে আশরাফুল মাখলুকাত ।

মুশরিক-মুনাফিকে মিলবে না শান্তি, এহকালে-পরকাল

লানতে ধ্বংস অনিবার্য

এ যে বিধাতার শপথ, চিরন্তন সত্য ।।

 

ফিরে এসো ভাই,

ফিরে এসো সব ।

নবীর আদর্শে,যা সুশীতল ছায়াতল

কর-প্রচার, করো প্রসার

আল্লাহ্‌ মনোনীত যে একমাত্র সত্য জিবনা-দর্শন তা হলো ইসলাম ।।

 



 

 

মোঃ আলমগীর হোসেন

লেখক, প্রভাষক, কম্পিউটার বিজ্ঞান ও প্রকৌশল বিভাগ,

প্রাইম বিশ্ববিদ্যালয়, বাংলাদেশ ।।

How to change the name of main function in c/cpp programming??


How to change the name of main function in c/cpp programming??

#best programming solution
#interesting programming solution C programming is the basic building block of programming or building logic. if we want to run or compile a program, we need to write our code under the main function which name is "main". Is there any way to change the name of this main function? The answer is yes, we can change the name of the main function in c/CPP. From this tutorial, you will learn, how to change the name of the main function in c or CPP.

Friday, November 13, 2020

Swapping two numbers using c syntax, function and the concept of class a...


Swapping two numbers by using the third variable. Swapping two numbers by using function. Swapping two numbers by using the concept of object oriented programming with cpp/c++

#best programming solution
#interesting programming solution

CPP tutorial, Constructor overloading in object-oriented programming wit...


Constructor overloading in object-oriented programming with cpp/c++ What is an overloading constructor in oop with cpp? Constructor overloading in cpp/c++. Constructor overloading with proper example.
#best programming solution,
#interesting programming solution

For all this question answer go to this video.

Sunday, October 18, 2020

Addition subtraction using class and object in C++

#include<iostream>
using namespace std;
class addSub{
public:
        int num1, num2;
        void inPut(){
                cout<<"Enter two values: "<<endl;
                cin>>num1>>num2;
        }
        void sum()
        {
                int s = num1 + num2;
                cout<<"Summation is: "<<s<<endl;
        }
         void sub()
        {
                int s = num1 - num2;
                cout<<"Subtraction is: "<<s<<endl;
        }
};
int main()
{
        addSub obj;
        int n;
        cout<<"Press 1 for summation, 2 for subtraction: ";
        while(cin>>n){
                obj.inPut();
                if(n == 1){
                       obj.sum();
                }
                else if(n == 2){
                        obj.sub();
                }
        }
        return 0;
}

Sunday, October 4, 2020

Major parts of a C program with proper example, 52D Batch

/*
        Author: Alamgir Hossain
        Date: 5/10/2020
        Purpose: to knowing major parts of a c program

*/// 1. Documentation part/documentation section
#include<stdio.h>//2. Linking part/Section
//#define x 50 //3. Definition Section
#define square(n) n * n
#define summation(num1, num2) num1 + num2//Macro
int p = 50;//4. Global Declaration Section/Part
char ch = 'z';
int multiply(int num1, int num2)//5. sub-program section
{
        int res = num1 * num2;
        return res;
}
void prime(){
        printf("Welcome to Prime University\n");
}
int main()//6. Main program section/part
{
        int x, y, r;
        x = 100;
        y = 200;
        printf("%d\n", x);
        prime();
        r = square(5);//Macro Calling
//        printf("%d\n", res);
        printf("%d\n", p);
        return 0;
}

Thursday, September 10, 2020

Function Overloading, operator overloading, function overriding in CPP/C++ || Polymorphism in CPP

 Function/Method Overloading in CPP/C++:

#include<bits/stdc++.h>

using namespace std;

class prime{

public:

        void sum(int a, int b)

        {

                printf("%d\n", (a + b));

        }

        void sum(int a, double b)

        {

                cout<<(a + b)<<endl;

        }

        void sum(double a, double b)

        {

                cout<<(a + b)<<endl;

        }

};

int main()

{

        prime obj;

        obj.sum(10.30, 20.45);

        return 0;

}



Operator Overloading in CPP/C++:

#include<iostream>

using namespace std;

int main()

{

        string s1, s2, s;

        s1 = "Prime ";

        s2 = "University";

        s = s1 + s2;

        cout<<s<<endl;

        int num1, num2, num;

        num1 = 100;

        num2 = 300;

        num = num1 + num2;

        cout<<num<<endl;

        return 0;

}

Method Overriding/Run Time Polymorphism:

#include<iostream>

using namespace std;

class prime{

public:

        void display(){

                cout<<"Prime, CSE Dept."<<endl;

        }

};

class cse : public prime{

public:

  void display(){

                cout<<"Prime, CSE Dept. from CSE class"<<endl;

        }

};

int main()

{

        cse obj;

        obj.display();

        return 0;

}





Monday, September 7, 2020

Different types of macro calling with proper example in C

 #include<stdio.h>

#define sum(num1, num2) num1 + num2//Macro Definition

#define multiplication(num1, num2, num3) num1 * num2 * num3

#define maximum(a, b) a>b?a:b

#define square(a) a * a

int main()

{

        int res = 64/square(4);

        printf("%d\n", res);

        return 0;

}





Sunday, September 6, 2020

Input and Output in Structure array with different function || Structure in C Programming || Input and Output in Structure

 Program -01

Structure Creation in C programming.

#include<stdio.h>

struct student

{

    int id;

    char name[100];

    double result;

};

int main()

{

        struct student std;

        scanf("%d", &std.id);

        scanf(" %s", &std.name);

        scanf(" %lf", &std.result);

        printf("%d %s %lf\n", std.id, std.name, std.result);

        return 0;

}


Program-02

Input and Output Function for a Structure in C Programming

#include<stdio.h>

struct student{

        int id;

        char name[100];

        double res;

        int contact;

};

void input()

{

        struct student s[5];

        int i;

        printf("Enter each student Information one by one: \n");

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

                scanf("%d %s", &s[i].id, &s[i].name);

                scanf("%lf%d", &s[i].res, &s[i].contact);

        }

}

void output()

{

        struct student s[5];

        int i;

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

                printf("Id: %d ", s[i].id);

                printf("Name: %s ", s[i].name);

                printf("Result: %lf ", s[i].res);

                printf("Contact: %d\n", s[i].contact);

        }

}

int main()

{

        input();

        output();

        return 0;

}







Tuesday, September 1, 2020

Some important abbreviation for IT Related Jobs

 

CODASYL: Committee/Conference of Data System Language

SNMP: Simple Network Management Protocol

WCCP: Web Cash Control Protocol

IPSLA: Internet Protocol Service Level Agreement

TCP: Transmission Control Protocol

UDP: User Datagram Protocol

FTP: File Transfer Protocol

SMTP: Simple Mail Transfer Protocol

DNS: Domain Name System

Thursday, August 27, 2020

C program to find first & second largest number in array

 /*

C program to find first & second largest number in array

        Array: 3, 10, 80, 20, 5

        Max1: 80

        Max2: 20


Logic:

        1. Input size and elements in array, store it in some variable say size and arr.

        2. Declare two variables max1 and max2 to store first and second largest elements.

        Store minimum integer value in both i.e. max1 = max2 = INT_MIN.

        3. Iterate though all array elements, run a loop from 0 to size - 1.

        4. Inside loop, check if arr[i] > max1

                max2 = max1

                max1 = arr[i]

        5. Else if arr[i] > max2 && arr[i] < max1

                max2 = arr[i]

*/

#include<stdio.h>

#include <limits.h>

int main()

{

        int size, arr[100], i, max1, max2;

        scanf("%d", &size);

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

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

        }

        max1 = max2 = INT_MIN;

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

                if(arr[i] > max1){

                        max2 = max1;

                        max1 = arr[i];

                }

                else if(arr[i] > max2 && arr[i] < max1){

                        max2 = arr[i];

                }

        }

        printf("%d %d\n", max1, max2);

        return 0;

}


Video Description: https://www.youtube.com/watch?v=6276kGaKEI4




Wednesday, August 26, 2020

C program to swap two numbers in different ways

 /*

Md. Alamgir Hossain

Lecturer, Dept. of CSE, Prime University

*/

//C program to swap two numbers

//Input:    a = 10, b = 25

//Output: b = 25, a = 10

#include<stdio.h>

int main()

{

        int a, b, temp;

        a = 10;

        b = 25;

        printf("Before swapping: a = %d, b = %d\n",a, b);

        /*

        temp = a;

        a = b;

        b = temp;

        */

        /*

        Using arithmetic operators + and -

        a = a + b;

        b = a - b;

        a = a - b;

        */

        /*

        Using arithmetic operators * and /

        a = a * b;

        b = a / b;

        a = a / b;

        */

        

        /*

        Using bitwise XOR operator ^

        a = a ^ b;

        b = a ^ b;

        a = a ^ b;

        */

        //Using bitwise XOR operator ^ in one line

       // a ^= b ^= a ^= b;

        //Using arithmetic operators + and - in one line

        //a = (a + b) - (b = a);

        //Using arithmetic operators * and / in one line

        //a = (a * b) / (b = a);

        printf("After swapping: a = %d, b = %d\n",a, b);

        return 0;

}



Monday, August 24, 2020

CPP program to check a number is prime or not using class and object

 /*
CPP program to check a number is prime or not using class and object
2, 3, 5, 7, .......
*/
#include<iostream>
using namespace std;
class prime{
private:
        int n, isPrime;//Data Members
public:
        prime(int num){//Constructor
                n = num;
        }
        void primeCk(){//Prime checking function
                isPrime = 1;
                if(n <= 1){
                        isPrime = 0;
                }
                for(int i = 2; i < n; i++){//10
                        if(n % i == 0){
                                isPrime = 0;
                                break;
                        }
                }
        }
        void display(){//Display function
                if(isPrime == 1){
                        cout<<"It's Prime"<<endl;
                }else{
                        cout<<"It's Not Prime"<<endl;
                }
        }
};
int main()
{
        prime obj(1);
        obj.primeCk();
        obj.display();
        return 0;
}



CPP program to calculate the Factorial of a number using class and object

 /*
Alamgir Hossain
Lecturer, Dept. of CSE, Prime University

CPP program to calculate the Factorial of a number using class and object
5! = 5 * 4 * 3 * 2 * 1 = 120
*/
#include<iostream>
using namespace std;
class factorial{
private:
        int num, fact;
public:
        factorial(int n){//Constructor
                num = n;
        }
        void factorialCalculate(){//Function for calculating factorial
                fact = 1;
                for(int i = num; i >= 1; i--){
                        fact = fact * i;
                }
        }
        void display()
        {
                cout<<"Factorial of: "<<num<<" is: "<<fact<<endl;
        }
};
int main()
{
        factorial obj(7);
        obj.factorialCalculate();
        obj.display();
        return 0;
}



C program to find maximum and minimum element in an array

 /*
Alamgir Hossain
Lecturer, Dept. of CSE, Prime University.

C program to find maximum and minimum element in array.
        Example: 20, 17, 10, 5, 50
        Max: 50
        Min: 5


Logic:
        1. Input size and element in array, store it in some variable say size and arr.
        2. Declare max and min to store maximum and minimum element.
        Assume first array element as maximum and minimum both,
        so, max = arr[0] and min = arr[0].
        3. Run loop from first to last array element i.e. 0 to size - 1
        4. Inside loop check each array elements,
        if (arr[i] > max), then update max = arr[i];
        if (arr[i] < min), then update min = arr[i];
*/
#include<stdio.h>
int main()
{
        int size, arr[100], max, min, i;
        printf("Enter the size of the array: ");
        scanf("%d", &size);
        printf("Enter the elements of the array: ");
        for(i = 0; i < size; i++){
                scanf("%d", &arr[i]);
        }
        max = min = arr[0];
        for(i = 0; i < size; i++){
                if(max < arr[i]){
                        max = arr[i];
                }
                if(min > arr[i]){
                        min = arr[i];
                }
        }
        printf("Maximum is : %d\n", max);
        printf("Minimum is: %d\n", min);
        return 0;
}



C program to count even and odd elements in an array

 /*

Alamgir Hossain

Lecturer, Dept. of CSE, Prime University.


C program to count even and odd elements in an array.
Array: 20, 12, 13, 50, 17
Even: 3
Odd: 2
*/
#include<stdio.h>
int main()
{
        int size, arr[100], i, even, odd;
        printf("Enter the size of the array: ");
        scanf("%d", &size);
        printf("Enter the elements of the array: ");
        for(i = 0; i < size; i++){
                scanf("%d", &arr[i]);
        }
        even = 0;
        odd = 0;
        for(i = 0; i < size; i++){
                if(arr[i] % 2 == 0){
                        even = even + 1;
                }
                if(arr[i] % 2 != 0){
                        odd = odd + 1;
                }
        }
        printf("Total even elements: %d\n", even);
        printf("Total odd elements: %d\n", odd);
        return 0;
}


Saturday, August 22, 2020

Major Parts of a C program with proper example

 
 
/*
        01. Documentation Section:
        Name: Alamgir Hossain
        Date: 23/08/2020
        For knowing about major parts.
*/
#include<stdio.h>//02. Linking Section/Part
#include<math.h>
#include<string.h>
#define abb 3.5670 //03. Definition Part
int x = 5;//04. Global Declaration Part
int y = 10;
char ch = 'c';
int main()//05. Main program section
{
        int  p =10;///Local Declaration
        prime();
        printf("%d\n", x);
        return 0;
}
void prime()//06. Sub-Program Section
{
        //printf("%d\n", p);
        int w = 200;
        printf("%d\n", x);
        printf("Welcome to Prime University\n");
}



Friday, August 21, 2020

Parameterized constructor in cpp/c++

 #include<iostream>
using namespace std;
class prime{
public:
        int id; //Data Member
        string name; //Data Member
        prime(int value, string s_name){//Parameterized Constructor
                id = value;
                name = s_name;
        }
        void display(){
                cout<<"Id is: "<<id<<endl;
                cout<<"Name is: "<<name<<endl;
        }
};
int main()
{
        int num;
        string name;
        cin>>num;
        cin>>name;
       // prime obj(120, "Bangladesh");
        prime obj = prime(num, name);
        obj.display();
        return 0;
}

Youtube video link: https://www.youtube.com/watch?v=fEnIx3lbXO4&list=UUkE_J-tXiqxzASO6nlB8D6w&index=2

Default constructor with proper example in cpp in bangla

 #include<iostream>
using namespace std;
class prime{
public:
        int id; //Data Members
        string name; //Data Members
        prime(){//Default Constructor
                id = 12345;
                name ="Bangladesh";
        }
        void display()//Output Function
        {
                cout<<id<<endl;
                cout<<name<<endl;
        }
};
int main()
{
        prime obj;
        obj.display();
        return 0;
}

Friday, March 13, 2020

Algorithm or Pseudocode and time complexity analysis for calculating maximum and minimum value from an array using divide and conqure method




Algorithm for calculating max and min value from an array:
    Algorithm maxmin(int low, int high, int max, int min)
    //low, high are used as index
    //max, min are used as max & min value
    {
        if(low == high) then
            min: = arr[low];
            max: = arr[high];
        else if((high -1 ) == low) then
            if(arr[low] < arr[high]) then
                max: = arr[high];
                min: = arr[low];
            else
                min: = arr[high];
                max: = arr[low];
        else
            mid: = (low + high)/2;
            maxmin(low, mid, max, min);
            maxmin(mid+1, high, max1, min1);
            if(max < max1) then
                max: = max1;
            if (min>min1) then
                min: = min1;
    }

Total time required for finding max and min value using divide and Conquer method:
 





So, in the asymptotic notation the time complexity of this algorithm is represented by O(n).