How to add array Elements with a constant

Data Structure / Array

1259

Program:


// 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

This Particular section is dedicated to Programs only. If you want learn more about Data Structure. Then you can visit below links to get more depth on this subject.