Problem Description
Write a program using pointers to insert a value in an array.Input and Output Format:Refer sample input and output for formatting specification.All float values are displayed correct to 2 decimal places.All text in bold corresponds to input and the rest corresponds to output.CODING ARENA
- #include <stdio.h>int main(){int j,i,n,b;scanf("%d", &n);int a[n];for (i=0;i<n;i++){scanf("%d",&a[i]);}scanf("%d", &b);scanf("%d", &j);for (i=n-1;i>=j-1;i--){a[i+1] = a[i]; }a[j-1]=b;for (i=0;i<=n;i++){printf("%d\n",a[i]);}return 0;}
Test Case 1
Input (stdin)399 199 2993991Expected Output39999199299Test Case 2
Input (stdin)41 2 3 452Expected Output15234
thanks this helps me alot Uses of c programming
ReplyDeleteThanks for the Program. You can also find more C Programs from here for future articles.
ReplyDelete