#include <stdio.h>
#include<stdlib.h>
int main(void) {
// creating a FILE variable
FILE *fptr;
FILE *wptr;
// integer variable
int numb,r,s=0;
char ch;
// open file for reading
fptr = fopen("D:/num.txt", "r");
//fail to open the file
if(fptr==NULL)
{
printf("\n Unable toopen the source file");
exit(0);
}
//open a file for writing
wptr = fopen("D:/numnew.txt", "w+");
//fail to open the file
if(fptr==NULL)
{
printf("\n Unable toopen the target file");
fclose(fptr);
exit(0);
}
//read data from num.txt
while (fscanf(fptr, "%d", &numb)!=EOF)
{
//reverse the number
s=0;
while(numb>0)
{
r=numb%10;
s=s*10+r;
numb=numb/10;
}
//write the reverse number into file
fprintf(wptr, "%d\n", s);
}
// close connection
fclose(fptr);
fclose(wptr);
}
INPUT
num.txt
output file
numnew.txt
Write a c program. CH-12 has arbitrary number of lines and one num. txt EXERCISE 12-11 te a program to create a new file numnew. txt that will he ine. A text file will have number in reverse order...
Write c program. Do part 4 and 5 CH-12 TEXT FILES SE 12-3 Create a text file named grade.txt that you type yourself by your Each record in grade.txt should have the following format: by Columns 1-4 6-8 number of a student A grade out of 100 EYERCISE 12-4 Write a program that will read the identification numbers of students and their letter grades (A, B, C, D, or F) from the keyboard and store them in a text file...
Write a c program CH-12 TEXT FILES EXERCISE 12-12 Write a program to read two files of the same length, and determine if they are equal. For example: if one of the file has the content 123 abc 45 bye! and the other has 123 abc 55 bye! then these files are not equal CH-12 TEXT FILES EXERCISE 12-12 Write a program to read two files of the same length, and determine if they are equal. For example: if one...
matlab Example: Function Name: battleFormation formation([3 5 11, formation1.txt) Inputs: (double) 1xN vector of the number of soldiers each line 2. (char)A file name, indluding extension, for the output file group number Formation1.txt: 1 Line 1 has the following line up: e 1 1 1 0 File Outputs: 21 Line 2 has the folloOwing line up: 1 1 1 1 1 1. A text file showing the soldiers formations 3 Line 3 has the following line up: e e 1...
Character Count Write a program that reads a file and counts the number of occurrences of each character in the file (case sensitive). The file name is "char.txt". You should use a dictionary to hold the number of occurrences of each character, and print out that dictionary. For example, if the file contains only six characters, "tactic", your dictionary should contain the following key-value pairs (order can be different): {'a': 1, 'c': 2, 'i': 1, 't': 2} Sample Input: Follow...
matlab Example: Function Name: battleFormation formation([3 5 11, formation1.txt) Inputs: (double) 1xN vector of the number of soldiers each line 2. (char)A file name, indluding extension, for the output file group number Formation1.txt: 1 Line 1 has the following line up: e 1 1 1 0 File Outputs: 21 Line 2 has the folloOwing line up: 1 1 1 1 1 1. A text file showing the soldiers formations 3 Line 3 has the following line up: e e 1...
I am confused on how to read valid lines from the input file. I am also confused on how to count the averages from these valid input lines to keep running the total from these valid lines. If you could show an example of an input and output file that would be amazing as well. Purpose Learn how to use Java input/output. Due Date Per the Course at a Glance. Can be resubmitted. Submissions In this order: printed copy of...
Matlab Question 2. For this problem you have to create a program that defines two vectors of numbers: A and B and uses a for-loop to combine the values of A and B. Note that different parts of the question below specify different orders for combining the elements. To start this exercise start a MATLAB script called q2.m and put, at the top, the vector definition: B [11:20] Question 2a: Problem definition Copy the file q2.m to q2a.m. For this...
Write a c++ program in that file to perform a “Search and Replace All” operation. This operation consists of performing a case-sensitive search for all occurrences of an arbitrary sequence of characters within a file and substituting another arbitrary sequence in place of them. Please note: One of the biggest problems some students have with this exercise occurs simply because they don’t read the command line information in the course document titled “Using the Compiler’s IDE”. Your program: 1. must...
Tasks Write a program that prints in text mode Project 2 written by YOURNAME And shows in a graphical way, as shown below, the names stored in a file. The coordinates to print the names will be also read from another file. Here is an example of what your graphic output should look like with the two files that are provided for test purposes. Drawing Panel Adam Bernie Cameron Daniel Fanny Gerard Harold Issac Jackie Raitlyn Note that the colors...