#include <stdio.h>
int main()
{
int arr[] = {10, 15, 20, 25, 30};
int *ptr;
int i, count = 0;
ptr = arr;
for(i = 0; i < 5; i++)
{
if(*(ptr + i) % 2 == 0)
{
count++;
}
}
printf("Total Even Numbers = %d", count);
return 0;
}
Total Even Numbers = 3
Pointer Arithmetic ব্যবহার করে Array এর প্রতিটি element access করা হয়েছে এবং Even সংখ্যা গণনা করা হয়েছে।
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.