4. Write a C function that takes two integers as arguments and returns the value of the larger one.
Q: 4. Write a C program to implements variables using call by reference. a function for swapping…
A: Language is one of the most widely used programming language which has been used to create different…
Q: FOR C++, ANSER THESE QUESTIONS IN THE GIVEN CODE BELOW Define functions corresponding to the…
A: In C, files having the.h extension are known as header files. These header files usually include…
Q: Write a C++ function that accepts a double typed number and return back the fractional part of the…
A: C++ Code for as par your requirements: it prints only fractional parts. #include <iostream>…
Q: Write a function in C language which takes an integer as parameter and returns the sum of all non…
A: Write a function in C language which takes an integer as parameter and returns the sum of all non…
Q: Write a function in C++ that takes input an integer parameter and return the reverse of that string.…
A: Here have to determine about c++ code for reverse the number.
Q: Create a C++ function to take a string as a parameter and then store every character of the string…
A: Create a C++ function to take a string as a parameter and then store every character of the string…
Q: 2. Write simple programs to illustrate the concepts of following in C++:- a. Program to calculate…
A: A)Program to find the area of various geometrical shapes by function overloading.…
Q: What is the distinction between an Inline Function and a Regular Function?
A: Introduction The question is about distinction between an Inline Function and a Regular Function and…
Q: Write a program in C to take a function name calculation() and in the function calculate the average…
A: C program to create a function named calculation (). This function calculates the average of the…
Q: Write a Function in C++ to find the minimum between two numbers that entered by user using pointer .
A: #include<iostream> using namespace std; int greatest(int* a,int* b) { int r;…
Q: Write a C++ function that takes an array and its size as parameters, then calculates and returns the…
A: Introduction of the Program: The C++ program defines a function that returns the maximum value of…
Q: Write a Program in C++ for a grocery shop payment bill/ receipt. The program should display the…
A: Algorithm : Step 1 : printing the output as required Step 2 : using \t as tab for spaces and also…
Q: Q #2: Write a program in C to check a given number is even or odd 1. Using the function with no…
A: C CODE:- #include <stdio.h>#include <stdbool.h>bool checkNumber(int num); int main(){…
Q: 1. Write a function in C++ to swap values of integers using reference variables.
A: Pass by reference : Passing arguments to the function using the address of the variables is called…
Q: 5. Write a C function that takes a positive integer n as an argument and returns 1 if n is prime,…
A: Given: To write a C function that takes a positive integer n as an argument and returns 1 if n is…
Q: Write a C++ function which receive two files as parameter and display its common words. Write helper…
A: ifstream firstFile("c:/a.txt"),secondFile("c:/b.txt"); string fFileStr,sFileStr;…
Q: Write a function in C++ that takes a string as a parameter and replaces all the digits in the string…
A: //Import iostream and cctype#include <iostream>#include <cctype> using namespace std;…
Q: 14. Create a functional program in C++ that takes a string as the parameter. The string will contain…
A: Create a functional program in C++ that takes a string as the parameter. The string will contain…
Q: write c++ program to pass three integer numbers as a parameter to a function called average which is…
A: Formula to calculate the average of three numbers : If a, b and c are three integer variables then…
Q: Write a C++ function to take two integer parameters and return the product of both the numbers.
A: the code is given below :
Q: Write a function that takes two numbers as parameters and returns their LCM. solve it in C++
A: The C++ code for given question in step-2.
Q: n, c programming, write a character-valued function named convertroGrade that has a single type int…
A: Given: required: write a character-valued function named convertroGrade that has a single type…
Q: 2. If a function have all the default arguments but still some values are passed to the function…
A: Question 2. If a function have all the default arguments but still some values are passed to the…
Q: Write a C++ struct definition, fraction, suitable for representing a fraction in non-decimal form.…
A: Program approach: Include the header file. Prototype the function named sumfrac(). Define the…
Q: Write a Function in C++ named divThree that receives an integer number x and print all number that…
A: CODE: #include <iostream>using namespace std;void divThree(int);int main(){ int x;…
Q: Create a C# function that takes a number (from 1 to 12) and returns its corresponding month name as…
A: I give the code in C# along with output and code screenshot
Q: 3. Write a C program to define a user-defined function which will accept a range and display all…
A: Step 1 : Start Step 2 : Define a function showPrime which takes an array as a list of numbers as…
Q: 2. Write a C++ program that adds three numbers of different numeric data types (e.g. integers,…
A: Please note that we are only allowed to solve only question in one post. I am solving the first one…
Q: Question 2. Write a C function that replace a character by a blank (space) in a string. Both the…
A: The programming methodology for the program is given by: Including header files Function prototype…
Q: 11. Write a C++ function that takes the name of a variable inside a string variable and returns true…
A: There are various rules while declaring the names of variable and we need to check each of the rules…
Q: C++ Can a variable name be passed to a value parameter in C++ functions?
A: Yes, a variable name is passed to a value parameter in C++ functions. Explanation: Parameter:…
Q: What does a function definition consist of? An invocation of a function's name A list of all other…
A: GIVEN:
Q: Write a function called incrementBy that takes two integers, one by reference and one by value, and…
A: #include<stdio.h>//here is my increment by function it will accepts two argument first value…
Q: Create a function in c++ to calculate the average of three numbers and call this function from main…
A: Program Approach - Include the important header files. Define the function named calcavg() to…
Q: Write a C function strUpper() that takes a string as a parameter, and converts all lower case…
A: Given: We are given a problem in the C language. Goal: We have to design a C function that takes a…
Q: Write a C++ function that takes an array and its size as parameters, then calculates and returns the…
A: GIVEN: Create a C++ program with function that takes an array and its size as parameters, then…
Q: Q2 / I write a program in C ++ to calculate the value of the following relationship, using the…
A: Algorithm: 1. Start 2. Read k value 3. Write factorial function to calculate factorial of the number…
Q: d. When a return statement executes in a user-defined function, the function immediately exits. A…
A: Given: Mark the following statements as true or false:
Q: Q3: Write a C++ code of an integer function that has two integer parameters passed by reference, and…
A: Step 1:- Program Approach:- 1.Declare the user-defined function whose name is mode(int &a, int…
Q: Write a function that receives marks received by a student in 3 subjects and returns the average and…
A: #include<stdio.h> float calculateAverage(float m1,float m2,float m3){ float…
Q: Write a C++ function named greater_10. This function returns an int and has two integer arguments,…
A: int greater_10(int number1, int number2){ if((number1+number2)>10) { return (number1 +…
Q: Write the following in C++ Write three functions, float getNum(), float add(float, float), void…
A: The C++ program and approach are given below:Approach: Declaring the essential headers and the…
Q: 2. Write a C function to take two integers n,p as the parameters and return the value of "P, given…
A: Write a C function to take two integers n,p as the parameters and return the value of nPr given that…
Q: Consider the following function definitions: Which of the following function calls will be rejected…
A: The third function call i.e. find("why"); will be rejected by compiler The reason is that the…
Q: 7. Write a function with one integer parameter that will return the sum of the divisors of its…
A: [Note: Explanation of the program code is provided within the comments.] Program code:…
Q: 3. Write a C++ program to find the square root of a number using the property that the sum of first…
A: Write a C++ program to find the square root of a number using the property that the sum of first n…
Q: What is the definition of an inline function?
A: Introduction: An inline function is one for which the compiler instead of constructing a distinct…
Q: Write a c++ function named swap value which take 5 number array as argument and swap its values in…
A: given task: to create a program to take 5 number array and reverse it using swap.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
- Hello, How can I store a whole book in a file in c language? I had some issues because the string is too long. here is the question: For this assignment I have uploaded a large text file that contains the entire book “Robinson Crusoe” byWilliam Defoe as file defoe-robinson-103.txt Consider the code shown below. It uses the fgets function.fgets is used to read (“get”) strings (“s”) from a file (“f”), hence the name “fgets”. It takes the following arguments:1. A pointer to an array large enough to store the string. In our case that is the char array calledbuffer of size MAX.2. The size of the array, in our case the symbolic constant MAX, set equal to 4000 in line 4.3. The file pointer of the file to read from, in our case bkPtr. Each call to fgets returns a string until the newline (“\n”) character or EOF is encountered. The codereads strings from the file defoe-robinson-103.txt in the while loop and prints them to screen.Implement this program and run it.C++ is my answers correct ? Write a function to convert a decimal number to a binary number. Answer: #include <iostream> #include <string> using namespace std; string decToBin(int dec) { string bin = ""; while (dec > 0) { bin = to_string(dec % 2) + bin; dec /= 2; } return bin; } int main() { cout << decToBin(10) << endl; return 0; } Write a function to calculate s =1!+2!+3!+....+10! Answer: #include <iostream> using namespace std; int findFactSum(int n) { int f = 1, Sum = 0; for (int i = 1; i <= n; i++) { f = f * i; Sum += f; } return Sum; } int main() { int n = 10; cout << findFactSum(n); return 0; }I need this Code By C++ Please stick to the code at the bottom of the page Just By C++. The file text.txt contains a sentence text written in all small letters and does not have any punctuation marks, no numbers, no symbols except for spaces. You are required to write a program which accepts an operation code, and zero to two inputs depending on the operation code. Based on the operation code, you will call three versions of the overlaoded function textProcessing as follows: Operation 0: The function removes all vowels from the ORIGINAL sentence. The vowels considered are the small letters (a, e, i, o, u y, and w). Operation 1: The code further asks for one lowercase letter to be input by the user. If the character is not a lower case letter, the code outputs Invalid. The function returns the distance (difference) between the letter first occurence and last occurence in the text. If the letter does not occur in the sentence, it returns 0. Operation 2: The code asks for two…
- Task 1. Create a C file and declare declare the following variables in your main function: char string1[12] = "hello"; char string2[12] = "hello\n"; char string3[12] = "hello\n\0you\n"; char string4[12] = "0123456789AB"; The first function that we will write is the void printArray(char a[], int length) function. It has an array of characters as input and an integer that indicates the length of the array. void signifies that it has no return value. The function prints the '[' character and then all characters in the array, separated by commas, finally followed by the ']' and '\n' characters. When a character in the string is null then you should print \0, i.e. the backslash character followed by ’0’. When a character in the string is the newline character then you should print \n, i.e. the backslash character followed by ’n’. Call printArray with each of the string variables as input. The output should be as follows: [h,e,l,l,o,\0,\0,\0,\0,\0,\0,\0] [h,e,l,l,o,\n,\0,\0,\0,\0,\0,\0]…(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.3. Write a function that uses regular expressions to extract SIN numbers with either dashes or spaces between the numbers, but not any other characters. E.g. the string 'My SINs are 123-456-798 and 987 654 321, and 987/432/321' should return the list ['123-456-798', '987 654 321']
- Create a file called search_replace.py. Here, create a program thatimplements a search and replace function recursively. Your programshould allow a user to enter a string, a substring they wish to find andanother string with which they wish to replace the found substring. Consider finding the index of the string you want replace then use concatenation and slicing to join the different parts togetherThe output of your program should be similar to the output given below:Please enter a string: Hello worldPlease enter the substring you wish to find: lloPlease enter a string to replace the given substring: @@Your new string is: he@@ worldAnswwr asap 9.Write a function hello(firstname, lastname), which, for example, if called with hello('James, 'Barth'), would print two lines: Hello James Barth Hello Barth, James. Use the function in a program where you ask the user for first and last name and then call the function.?13. Write function quote() that takes as input the name of a file (as a string) and anindex i (as an integer). The file will contain quotes, one per line. The function shouldopen the file, read the file, close the file, and return the i-th quote (i.e. the i-th line in thefile), assuming that the quote numbering starts at 0. Test your solution onfile Wilde_Quotes.txt.>>> quote("Wilde_Quotes.txt", 5)'At twilight, nature is not without loveliness, thoughperhaps its chief use is to illustrate quotations from thepoets.\n'>>> quote("Wilde_Quotes.txt", 0)'A little sincerity is a dangerous thing, and a great dealof it is absolutely fatal.\n'>>> quote("Wilde_Quotes.txt", 23)'Patriotism is the virtue of the vicious. \n'>>>
- This is for devc++ version 5.11 Use the following code to create a function to find the sum of digits in a number. Your function SumOfDigits should take an integer and return an integer. Call this function from main inside a while loop which keeps taking the input until the number is b/w 1 and 1000. #include <iostream>using namespace std;int main(){int digit,sum=0;int i =3456; /// 3456 % 10 = 6 -----------------------/// 3456/10 = 345//// 345 %10 = 5----------------------------//// 345/10 = 34/// 34%10 = 4---------------------------------/// 34/10 = 3// 3%10 = 3 ----------------------------------/// 3/10 = 0 STOPi=3456;while (i!=0){digit = i %10;cout << digit << " ";sum+=digit;i=i/10;}cout <<"Sum of digits "<<sum;}DataFile.txt contains the information of poker cards. 1. C: clubs (lowest), D: diamonds, H: hearts, S: spades (highest) 2. 2 (lowest), 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A 3. No Joker cards 4. Any C cards are lower than any D cards. DataFile Content (You can write the file specification into your program.) : H4,C8,HJ,C9,D10,D5,DK,D2,S7,DJ,H3,H6,S10,HK,DQ,C2,CJ,C4,CQ,D8,C3,SA,S2,HQ,S8, C6,D9,S3,SQ,C5,S4,H5,SJ,D3,H8,CK,S6,D7,S9,H2,CA,C7,H7,DA,D4,H9,D6,HA,H10,S5,C10 H4, D5, HK, D2 H4, HK, SK C9,C10 1. Create a list by dynamic allocated array and set the size to 20 2. Read the first 20 cards in the first line of the file, the put them one by one into the list by implementing and using putItem(). The list must be kept sorted in ascending order. Then print out all the cards in the list in one line separating by commas. 3. Then delete the cards indicated in the second line of the file by using deleteItem() Then print out all the cards in the list in one line separating by commas. 4. Then put…7. Write a function password_check() that takes as input two stringsnewpassword and oldpassword, and that accepts the new password (i.e., returnsTrue) if newpassword is different from oldpassword and newpassword is atleast 6 letters long. If the new password fails the check, your functions should returnFalse.>>> password_check('E10-s2ff', 'E10.s2ff')True>>> password_check('E10sf', 'E10.s2ff')False>>> password_check('E10-s2ff', 'E10-s2ff')False(Extra Credit) For extra credit, extend your password function so that it also checks thatthe new password contains a digit.>>> password_check('E10-s2ff', 'E10.s2ff') True>>> password_check('Eej-sdff', 'E10.s2ff')False