Home / Programs / C Program to add array Elements with a constant
Programming Example

C Program to add array Elements with a constant

👁 1,322 Views
💻 Practical Program
📘 Step by Step Learning
add array Elements with a constant

Program Code

// 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]);
    }
}

Output

10 11 12 13 14 15 16 17 18 19 20 21 

Explanation

none

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.