Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/
#include <stdio.h>
int main()
{
int N, i, k,LB,UB;
scanf("%d", &N);
int LA[N];
for(i=0; i<N; i++) scanf("%d", &LA[i]);
scanf("%d%d", &LB, &UB);
for(k=LB; k<=UB; k++) LA[k]+=5;
for(i=0; i<N; i++) printf("%d\t", LA[i]);
printf("\n");
return 0;
}
Second input LA[i] = input N element one by one. ex. 3 5 7 9 11 13 15 17
Third input LB = From Which Index I Want to Change. ex. 2
Forth input UB = Till Which Index I Want to Change. ex. 5
I add 5 on every Index from LB to UB.
You can do anything you want by changing a little bit 8-).
Output ex. 3 5 12 14 16 18 15 17
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.