// How to add array Elements with a constant
#include<stdio.h>
void main()
{
int array[] ={0,1,2,3,4,5,6,7,8,9,10,11};
// Here the constant vale is 10
ExtOp(array,10,0,11); // function calling
}
void ExtOp(int array[],int MyCon,int start,int finish)
{
int i=start;
for(i=0;i<=finish;i++)
{
//multiplication with every element
array[i]+= MyCon;
printf("%d ",array[i]);
}
}
10 11 12 13 14 15 16 17 18 19 20 21
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.