Pointer and array example + pointer arithmatic (using ++,+ etc.)

#include<stdio.h> int main() { int B[4] = {20,30,40,50}; int *P,K; P = B; //এখানে B অ্যারের প্রথম ইনডেক্স এর ভ্যালু ২০ কে P তে রাখলাম। printf("*P = %d\n",*P); //P এখন যাকে পয়েন্ট বা নির্দেশ করতেছে সেটা প্রিন্ট করতেছি K = ++(*P); //P pointer যাকে পয়েন্ট করতেছে তার মান এক বাড়িয়েছি।মানে ২০ এখন ২১ printf("++(*P) = %d\n",K); printf("++(*P) = %d\n",++*P); // ২১ এখন ২২ printf("++(*P) = %d\n",++*P); // ২২ এখন ২৩ printf("++(*P) = %d\n",++*P); // ২৩ এখন ২৪ printf("\n\n\n"); printf("*P = %d\n",*P); ///এখানে P এর সর্বশেষ মান টি থাকবে। অর্থাৎ ২৪ K = *(P+1); //এখন P এর ইন্ডেক্স এক বেড়ে গেছে, অর্থাৎ B[1] = 30 printf("*(P+1) = %d\n",K); printf("*(P+2) = %d\n",*(P+2)); printf("*(P+3) = %d\n",*(P+3)); return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.