Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int arr[50], var, x, p, num, m;
- printf("Enter the position : ");
- scanf("%d", &p);
- printf("Enter the number : ");
- scanf("%d", &x);
- FILE *fp, *fpw;
- fp = fopen("F:\\inputr.txt", "r");
- fpw = fopen("F:\\outputr.txt", "w");
- int i = 0, j = 0;
- while(fscanf(fp,"%d",&arr[i])!=EOF)
- {
- i++;
- }
- for(j=i; j>=p-1; j--)
- {
- arr[j]=arr[j-1];
- }
- arr[p-1]=x;
- for(j=0; j<=i; j++)
- {
- num = arr[j];
- while(num != 0)
- {
- m = num % 10;
- num = num / 10;
- }
- fprintf(fpw, "%d ", m);
- }
- fclose(fp);
- fclose(fpw);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement