This program is about to update and print the element in array using array and for loops
#include<stdio.h> int main() { int i,t,a[10],n,m,s,j=0,b[10]; printf("\nEnter the Limit:"); scanf("%d",&n); printf("\nEnter the Values:"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } printf("\nGiven values are:"); for(i=0;i<n;i++) { printf("a[%d]=%d",i,a[i]); } printf("\nEnter the position to be update:"); scanf("%d",&t); printf("\nEnter the value to be update:"); scanf("%d",&s); for(i=0;i<n;i++) { if(i==t) { a[i]=s; } } printf("\nUpdated value is:"); for(i=0;i<n;i++) { printf("\na[%d]=%d",i,a[i]); } return 0; }To download raw file Click Here
Enter the limit:5 Enter the values:1 2 3 4 5 Given values are: a[0]=1 a[1]=2 a[2]=3 a[3]=4 a[4]=5 Enter the position to be update:3 Enter the value to be update:5 Inserted value is: a[0]=1 a[1]=2 a[2]=3 a[3]=5 a[4]=4 a[5]=5
Learn All in Tamil © Designed & Developed By Tutor Joes