C PROGRAM:
#include<stdio.h>
#include<stdlib.h>
//main
int main()
{
//variables declaration thres for threshold value & x to read data from file
int thres,x;
//char type array to input file name and store
char filename[200];
printf("Enter the file name: ");
scanf("%s",filename); //filename input
printf("Enter the threshold value: ");
scanf("%d",&thres); //threshold value input
//opening and creating files
FILE *fread; //input file open
fread = fopen (filename, "r"); //here r keyword is to read from file
FILE *feven; //even number file
feven = fopen ("even.txt", "w"); //here w keyword is to write in file
FILE *fodd; //odd number file
fodd = fopen ("odd.txt", "w"); //here w keyword is to write in file
//showing input values on screen
printf("Input file values: ");
//loop to read till EOF and evaluate all values from input file
// and writing outputs in even.txt and odd.txt accordingly
while((fscanf(fread,"%d",&x))!= EOF) //EOF: end of file
{
printf("%d ",x);
if(x>thres) //checking threshold
{
if(x%2==0)
fprintf(feven,"%d ",x); //writing in even.txt
else
fprintf(fodd,"%d ",x); //writing in odd.txt
}
}
//closing all files
fclose(fread);
fclose(feven);
fclose(fodd);
printf("\n\n");
return 0;
}
OUTPUT:

INPUT FILE:

even.txt file created:

odd.txt file created:

in c prog only please!! Name this program one.c - This program takes two command line...
C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...
In C please
Create a program that takes two integers as command line
arguments (num, length) and outputs a list of the first length
multiples of num. num should be included in the returned array.
For example:
./a.out 7 5 -> [7, 14, 21, 28, 35]
./a.out 12, 10 -> [12, 24, 36, 48, 60, 72, 84, 96, 108,
120]
./a.out 17, 6 -> [17, 34, 51, 68, 85, 102]
Ma Word starts with a vowel add "yay" to the...
Modify When executing on the command line having only this program name, the program will accept keyboard input and display such until the user does control+break to exit the program. The new code should within only this case situation “if (argc == 1){ /* no args; copy standard input */” Replace line #20 “filecopy(stdin, stdout);” with your new code. Open read a text file “7NoInputFileResponse.txt” that contains a message “There were no arguments on the command line to be tested...
2. Write a function file_copy() that takes two string parameters: in file and out_file and copies the contents of in_file into out file. Assume that in_file exists before file_copy is called. For example, the following would be correct input and output. 1 >>> file_copy( created equal.txt', 'copy.txt) 2 >>> open fopen ( copy.txt') 3 >>> equal-f = open( 'created-equal . txt') 4 >>equal_f.read () 5 'We hold these truths to be self-evident, Inthat all men are created equalIn' 3. Write:...
Write a C program that reads a list of positive integers from a file named "input.txt." and count number of odd integers and even integers and prints the results to another file called "results.txt". Please submit both the input and results files along with the c program.
Objective: Use input/output files, strings, and command line arguments. Write a program that processes a text file by removing all blank lines (including lines that only contain white spaces), all spaces/tabs before the beginning of the line, and all spaces/tabs at the end of the line. The file must be saved under a different name with all the lines numbered and a single blank line added at the end of the file. For example, if the input file is given...
Command line input In C++ it is possible to accept command line arguments. Command-line arguments are given after the name of a program in command-line operating systems like Linux and are passed in to the program from the operating system. To use command line arguments in the program, it must first understand the full declaration of the main function, which until now has accepted no arguments. In fact, main can accept two arguments: one argument is number of command line...
Help please
Write a program named one.c that takes a single command-line argument, the name of a file. Your program should read all the strings (tokens) from this file and write all the strings that are potentially legal words (the string contains only upper-case and lower-case characters in any combination) to the file words. Your program should ignore everything else (do not write those strings anywhere 1. As an example, running /a.out dsia would result in the generation of the...
C Language Programming. Using the program below - When executing on the command line only this program name, the program will accept keyboard input and display such until the user does control+break to exit the program. The new code should within only this case situation “if (argc == 1){ /* no args; copy standard input */” Replace line #20 “filecopy(stdin, stdout);” with new code. Open read a text file “7NoInputFileResponse.txt” that contains a message “There were no arguments on the...
In
c language. I have to read 3 files and used the numbers in the file
in a program. An example of the 3 files are below. How do read the
numbers, I realize it’s with arrays. The input won’t have more than
100 lines but it can have less n
3. Input Files The filename includes the variable name and the sensor number as: variable name <sensor id txt For example "BT 0001.txt" is the file that contains the...