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

🖥 Program Output

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

📘 Explanation

none
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

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.

🔥 Practice suggestion

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.