Home / Programs / Pointer ব্যবহার করে দুটি String তুলনা
🚀 Programming Example

Pointer ব্যবহার করে দুটি String তুলনা

👁 0 Views
💻 Practical Program
📘 Step Learning
Learn this program step-by-step with algorithm, source code, output and detailed explanation.

📌 Information & Algorithm

  1. দুটি string declare করুন।
  2. দুটি pointer ব্যবহার করুন।
  3. Character by character তুলনা করুন।
  4. একই হলে message দেখান।

💻 Program Code

#include <stdio.h>

int main()
{
    char str1[] = "Hello";
    char str2[] = "Hello";

    char *p1, *p2;

    p1 = str1;
    p2 = str2;

    while(*p1 == *p2 && *p1 != '\0' && *p2 != '\0')
    {
        p1++;
        p2++;
    }

    if(*p1 == '\0' && *p2 == '\0')
    {
        printf("Strings are Equal");
    }
    else
    {
        printf("Strings are Not Equal");
    }

    return 0;
}
                        

🖥 Program Output

Strings are Equal
                            

📘 Explanation

দুটি Pointer ব্যবহার করে String এর প্রতিটি character তুলনা করা হয়েছে। সব character একই হওয়ায় String দুটি equal হয়েছে।

📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.