#include <stdio.h>
int main()
{
int arr[] = {10, 20, 30, 40, 50};
int *ptr;
int i, sum = 0;
ptr = arr;
for(i = 0; i < 5; i++)
{
sum = sum + *(ptr + i);
}
printf("Total Sum = %d", sum);
return 0;
}
Total Sum = 150
এখানে Pointer Arithmetic ব্যবহার করে Array এর প্রতিটি element access করা হয়েছে। *(ptr + i) দ্বারা প্রতিটি element এর মান পাওয়া যায়।
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.
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.