Write a C function named int getNumberOfWords( FILE* fp) which finds the number of lines in the given file. Here, assume the file is already opened in read mode and return value of fopen is assigned to fp. For example: Test Input Result printf("%d", getNumberofWords (stdin)); aaabb124 bcdf 4 ccccccccccccc cc c C ccccddddddd dddddddddddddddddd ееееееееееееееееееееее aaxx; ddfeart
Q: Suppose that you have a text file (temperature.txt) that contains registered temperatures for a…
A: Program execution as follows. use ifstream for reading the file read the temperature value…
Q: Write a function that reads a single line of numbers from a file named "question1.txt", and returns…
A: Algorithm: Step1: Open the text file in read write mode. Step2: Read the line with numbers and split…
Q: P1. Write a Python function called reduceWhitespace that is given a line read from a text file and…
A: the- program code in python is given below:
Q: Write a program that computes and prints the average of the numbers in a text file. You should make…
A: code :
Q: Mrite a function that takes two lists of integers x and Y as input, and computes and writes a table…
A: def op2file(X, Y): f = open("C:\\Users\\Dell\\OneDrive\\Desktop\\question2.txt", "w") for i in…
Q: write a program that computes and prints the average of the numbers in a text file. you should make…
A: in step 2, I have provided TXT FILE SCREENSHOT--- in step 3, I have provided PYTHON CODE---…
Q: Write a C++ function that meets the following specification. Name: wordFinder Inputs: 1) input…
A: The main objective of the program is to create a C++ program that will implement the wordFinder…
Q: 1.Liz buys three apples, a dozen bananas, and one cantaloupe for $2.36. Bob buys a dozenapples and…
A: MATLAB code is given below
Q: in c++ : Write a function to count number of words in a text file named "story.txt".
A: Code: #include <iostream>#include <fstream> using namespace std; int main() { string…
Q: I have this code in C++ which contain two function and one main . I have difficulty to understand…
A: The checkfile function checks if a file is sorted or no and returns a Boolean value for it. If ASCII…
Q: Write a function that reads a single line of numbers from a file named "question1.txt", and returns…
A: Given: Write a function that reads a single line of numbers from a file named"question1.txt", and…
Q: Write a function find_decrypted_words() that takes a file name as parameter, reads that text file…
A: Given:
Q: f(x)= x + 3 when x= 8 Create a function M-file, PieceZigZag, that accepts one or more values as…
A: The complete answer is given below .
Q: Write a C++ program that computes student grades for an assignment as a percentage given each…
A: the program ia an given below :
Q: 2. Write a complete C program that inputs marks of a student in 5 courses using any loop and writes…
A: The code is given below
Q: Python: Character Histogram
A: Summary: In this question, we have been one program and we have to write the code in python. In…
Q: A formatted file master.txt contains the employee code, name and basic pay of employees of an…
A: #include <stdio.h> int main(){ int code, count = 0; float basic, hra, da, gross; char…
Q: Complete the following program with two lines such that the data from the URL is retrieved into a…
A: we have to write the code
Q: Write a program that reads a text and outputs the letters, together with their counts, as explained…
A: The program should have the following functions: Function main – calls all the functions. Function…
Q: Task: Write a program, using functions only, with the following features. 1. Program reads…
A: Actually, string is a sequence of characters.
Q: Write a program to calculate the net pay of an employee, Input the basic pay, pass basic pay to user…
A: Objective: A program is built to insert the information about employees and calculate the net pay by…
Q: You will write a function that can be used to decrypt Dan’s encrypted text. You will be given an…
A: from string import punctuation # Function to shift string by a (shift) valuedef…
Q: 4. Write a program that counts the number of unique words in a text file; use gb.bxt as a test file…
A: The definition of the function readfile() is shown below. def readfile(fname):…
Q: Write a program that includes a function that alculates the equation F= x" sin x. Write the alues n,…
A: Since no programming language is mentioned, I am using python. Algorithm: Start Initialize a list…
Q: question1.txt", and returns the average of the numbers read. For example, if the file is as…
A: Begin by creating a text file and storing numbers in it. I have named my file question1.txt.…
Q: Write a function find_lowers() that takes a file name as a parameter, reads that text file, and…
A: Since no programming language is mentioned, I am using python. Algorithm: Start Read file name…
Q: Write a function named framestr that takes as input a string s, and PRINTS on the screen a framed…
A: len(s) find length of string s '-' * n '-' copy it n times if n=5 '-'*n = '-'*5 = '-----'
Q: The result of COM101 exam results are given in Grades.txt. Write a C program that reads student ids…
A: C - program reads an input text file called "Grades.txt" .The input text file contains the student…
Q: Write a function that reads a single line "question1.txt", and returns the average the file is as…
A: Begin by creating a text file and storing numbers in it. I have named my file question1.txt.…
Q: The file text.txt contains a sentence text written in all small letters and does not have any…
A: import java.io.*; import java.util.*; // We have a class named Main public class Main { // We…
Q: Write a program that reads a text and outputs the letters, together with their counts, as explained…
A: Program code: #include <iostream> #include <fstream> using namespace std; // Create a…
Q: Write a C++ function (along with helper functions if required) that takes a file stream as a…
A: Write a C++ function (along with helper functions if required) that takes a file stream as a…
Q: Write a function reverse_file(f) that takes a file name f. After your function runs, the lines in f…
A: file can be opened by specifying the file location and mode of operation
Q: The file text.txt contains a sentence text written in all small letters and does not have any…
A: import java.io.*; import java.util.*; // We have a class named Main public class Main { // We…
Q: Write a C function willH dle int copyFile (char filenamel, char filename2); Siven the names of a…
A: The function reads characters from the source file and copies into the destination file. If the…
Q: Write a function void saveByDept(char *fileName, char *deptName , student allStudents[], int size)…
A: The following is the solution In saveByDept method File is open in write mode and fprintf has been…
Q: The goal for this question: DISCLAIMER****** CODE MUST BE WRITTEN IN C CODE. NOT C++, C#, etc. To…
A: To create a program that MUST utilize the functions (argc, argv, char strstr, and possibly even…
Q: python Write a function that reads in a text file, and counts the number of times each word occursin…
A: The program first creates a file sample.txt and stores a string in it. Then it reads the created…
Q: Write a C++ function that meets the following specification. Name: wordFinder Inputs: 1) input…
A: NOTE: - Since the file is not given, hence a sample file is taken to implement the required C++…
Q: 1. Write a function in python to count the number of lines from a text file "story.txt" which is not…
A: Explanation: Given data write a python program to count the number of lines from a text file…
Q: Write a program which randomly rolls a die 100 times (results in one of the six sides). Use the…
A: Hi. Let's move on to the code in the next step. I have included comments in the code that will help…
Q: Write a function (in a file called convert_knots.cpp) that converts knots into miles per minute. The…
A: The program is written in C++. Check the program screenshot for the correct indentation. Please…
Q: C Programming Task Write a programme called pgmReduce which takes 3 arguments: 1. an input file…
A: #include<stdio.h> int main() { #ifndef ONLINE_JUDGE // getting input from input.txt file…
Q: : Assume that you have a text file named file1.dat contains some text written into it, write a…
A: Use one input file stream to read input file and one output file stream for writing
Q: Write a complete C++ program that helps a derk at Muscat Post Office, to do the following tasks:…
A: Given :
Q: Each line of a hockey file contains a four-digit year, a team name, and a two-digit number of wins.…
A: - We need to code the team problem. - We have to use python here.
Q: Your function must find the oldest pet of a given breed (3rd input parameter) from the inFile and…
A: 1. function max age : parameter infile outfile breed a. open both file in try block b.…
Q: Write a function that reads a single line of numbers from a file named "question1.txt", and returns…
A: The problem is based on finding the average of numbers after reading the data from the file in…
Q: Write a C function named void skip_a(FILE *fp,char *in) which prevents to write lower case letter…
A: To solve this we need to loop until we reach the end of the string which is indicated by '\0' and…
Q: Write a function charHistogram(filename: str) -> None that takes the file name of a text file and…
A: It is defined as a frequency distribution shows how often each different value in a set of data…
Step by step
Solved in 2 steps
- (5) Write a function called copy_even_lines() that takes two strings (filenames) as input parameters and copies every other line from the first file into the second. That is, counting from 0, it copies the 0th line, the 2nd line, the 4th line, etc. from the first file to the second file. You may assume that both files exist. (6) Write a python program that asks the user for two filenames and calls your function copy_even_lines() from (5) using those two filenames. If one or more files do not exist, your program must handle the exception by repeating the prompts until valid filenames are entered.Write a function count_character(filename, character) that takes in a filename and a character, both as strings, and returns the total number of times the given character occurs in the file. Examples: Contents of hello.txt:HelloHELLOHelloHELLO count_character('hello.txt', 'L') returns 4count_character('hello.txt', 'H') returns 4count_character('hello.txt', 'e') returns 2 Requirements: Please use Python Programming only Show screenshot of your work.Write a function that reads a single line of numbers from a file named "question1.txt", and returns the average of the numbers read. For example, if the file is as follows: ----- question1.txt ----- 1 3 5 -2 4 0 6 -2 -3 ------------------------- then the function must return 12/9 = 1.33333 """ def file_average(): return # Remove this line to answer this question
- Write a function that reads a single line of numbers from a file named "question1.txt", and returns the average of the numbers read. For example, if the file is as follows: ----- question1.txt -----1 3 5 -2 4 0 6 -2 -3------------------------- then the function must return 12/9 = 1.33333Write a function IN C LANGUAGE that splits the following data read from a file named info.txt and store the data into a struct as show in the example: typedef struct{char name[20];char gender[5];char dateOfAdmission[20];char dateOfBirth [20];char illness [20];char address [20];char bloodType[5]; } information; Abed Mukhles#M#2212019#01012000#Ear Infection#Jenin#O+ Here the values are: name:Abed Mukhles gender:M dateOfAdmission:2212019dateOfBirth:01012000illness:Ear Infectionaddress:JeninbloodType:O+ Same for:Nadia A. Ali#F#01102020#05101970#COVID-19#AlBireh#A-Write a complete C program that inputs marks of a student in 5 courses using any loop and writes these marks into an output file named txt. After that, it reads scores from myElements.txt and computes the grades based on the table below using a programmer-defined function char computeGrade(double score), and displays the grades on screen. Score Grade >= 90 A 80-89 B 70-79 C 60-69 D <= 59 F ----- please, write 1. the c program code 2. include comments on your code 3. contents of the file myElements.txt 4. sample output Thank you so much
- Each line of a hockey file contains a four-digit year, a team name, and a two-digit number of wins.Here is one such file, hockey.txt:2003maple leafs452020maple leafs351995senators181996maple leafs302000senators482012canadiens48The first line of the file, for example, says that in 2003 (year), the maple leafs (team name) had 45 wins.Write a function that takes an open hockey file and returns a list of tuples,where each tuple refers to a team name and that team's maximum number of wins in any year.Here is a sample call of the function on hockey.txt:>>> teams_and_most_wins(open('hockey.txt'))[('maple leafs', 45), ('senators', 48), ('canadiens', 48)]"""from typing import TextIOdef teams_and_most_wins(f: TextIO) -> list[tuple[str, int]]:'''f is an open hockey file.Each year has 4 digits and each number of wins has 2 digits.Return a list of tuples where each tuple storesa team name and that team's maximum number of wins in any year.Every team should appear in exactly one of the…Write a function called max_age(inFile, outFile, breed) for a (python program), that takes three strings as input parameters. The function reads all the data from the inFile (1st input parameter) and writes data to the outFile (2nd input parameter) as described below. Each line in the input file represents a pet record and has the following format. name, breed, age where name and breed are strings, and age is an integer value. Your function must find the oldest pet of a given breed (3rd input parameter) from the inFile and write the following information to the outFile. breed, total records of this breed name of the oldest pet, age of the oldest pet Note that outFile must only have these two lines of information. Suppose, inFile contains the following data: shadow, longhair, 3 poshi, bangal, 5 mikus, longhair, 4 tigger, calico, 9 If you call this function with breed = "longhair", then the following must be written in the outFile: longhair, 2 mikus, 4 Your…You are given a file consisting of students’ names in the following form: lastName, firstName middleName. (Note that a student may not have a middle name.) Write a program that converts each name to the following form: firstName middleName lastName. Your program must read each student’s entire name in a variable and must consist of a function that takes as input a string, consists of a student’s name, and returns the string consisting of the altered name. Use the string function find to find the index of ,; the function length to find the length of the string; and the function substr to extract the firstName, middleName, and lastName.
- Write a C program named toupper.c that reads the contents of a file, and writes to another file after changing all lowercase letters in the input file to uppercase. The name of the input file and the output file are to be passed as command line arguments. Assume there are only ASCII characters in the input file. The length of the input file is not known beforehand. So make sure your program keeps reading bytes until EOF is reached. Use the library function toupper to concert letters into uppercase. Example: The program is run from the command line as follows; C:\>toupper.exe infile.txt outfile.txt Suppose the contents of the input file infile.txt is: AbcdefG The contents of the output file outfile.txt should be: ABCDEFGWrite a program vote.cc that allows to read from a file vote.in thelast names of the candidates in an election and the number of votes received by eachcandidate. The program should then output each candidate’s name, the number of votesreceived, and the percentage of the total votes received by the candidate. Your programshould also output the winner of the election. Your program should have at least the following functions:(a) Write a function openFile that prompts a user to enter a file name and opens it.(b) Write a function closeFile that closes an open file.(c) Write a function getData that reads from the file the candidate names and theirnumber of votes received and returns them in 2 separate arrays.(d) Write a function sumVote that takes as its parameter an array of number of votesand returns the total number of votes.(e) Write a function computePercentages that takes as its parameters an array ofnumber of votes and returns an array of percentages of votes. Your function shoulduse…You are given a file consisting of students’ names in the following form: lastName, firstName, middleName. (Note that some students may not have middle names). Write a program that converts each name to the following form: firstName middleName lastName. Your program must read each student’s entire name in a variable and must consist of a function that takes input as a string, consists of student’s name, and returns the string consisting of the altered name. Use the string function find to find the index of the function length to find the length of the string; and function substr to extract the firstName, middleName, and lastName. Test your program with a file consisting of the following names: Miller, Jason Brian Blair, Lisa Maria Gupta, Anil Kumar Arora, Sumit Sahil Saleh, Rhonda Beth