Ans1 : multiplication function
#include <iostream>
using namespace std;
int multiply(int a, int b)
{
int mul = 0;
for(int i=0;i<b;i++)
{
mul += a;
}
return mul;
}
int main()
{
cout<<multiply(3,4);
return 0;
}
Output:

Ans 2: random function
#include <iostream>
using namespace std;
int randCount()
{
int num, count = 0;
for(int i=0;i<5;i++)
{
num = (rand() % (15 - 8 + 1) + 8);
if(num % 2 == 0)
{
count++;
}
}
return count;
}
int main()
{
cout<<randCount();
return 0;
}
Output:

Ans 3:
#include <iostream>
#include <stdlib.h>
using namespace std;
//Function for getting the product
int getProduct(int n)
{
int product = 1;
while (n != 0) {
product = product * (n % 10);
n = n / 10;
}
return product;
}
// Function to find the product of digits from L to R
int productinRange(int l, int r)
{
if (r - l > 9)
return 0;
else {
int p = 1;
// Iterate between L to R
for (int i = l; i <= r; i++)
p *= getProduct(i);
return p;
}
}
//Summary Function taking file arguments
int Summary(FILE *input, FILE *output)
{
int sum_even = 0,sum_odd = 0, cumu = 1;
int a, b;
fscanf(input, "%d", &a);
fscanf(input, "%d", &b);
fclose (input);
for(int i=a; i<=b; i++)
{
if(i%2==0)
{
sum_even += i;
}
else
{
sum_odd += i;
}
}
cumu = productinRange(a, b);
if(output == NULL)
{
// File not created hence exit
printf("Unable to create file.\n");
exit(EXIT_FAILURE);
}
fprintf (output, "Sum of even: %d\n",sum_even);
fprintf (output, "Sum of odd: %d\n",sum_odd);
fprintf (output, "Cumulative product: %d\n",cumu);
fclose (output);
}
int main()
{
FILE *myFile;
FILE * fp;
myFile = fopen("input.txt", "r");
fp = fopen ("output.txt","w");
Summary(myFile, fp);
return 0;
}
Input file:

Output file:

Ans 4:
#include <iostream>
#include <stdlib.h>
using namespace std;
//countConsonants Function taking file arguments
int countConsonants(FILE *input)
{
char line[1000];
fgets(line, 1000, input);
int vowels = 0, specialChar = 0;
for (int i = 0; line[i] != '\0'; ++i) {
if (line[i] == 'a' || line[i] == 'e' || line[i] == 'i' ||
line[i] == 'o' || line[i] == 'u' || line[i] == 'A' ||
line[i] == 'E' || line[i] == 'I' || line[i] == 'O' ||
line[i] == 'U') {
++vowels;
} else if ((line[i] >= 'a' && line[i] <= 'z') || (line[i] >= 'A' && line[i] <= 'Z')) {
continue;
} else if (line[i] >= '0' && line[i] <= '9') {
continue;
} else{
++specialChar;
}
}
cout<<"Text : "<<line;
cout<<"\nSpecial Character : "<<specialChar;
cout<<"\nVowels : "<<vowels;
fclose (input);
}
int main()
{
FILE *myFile;
myFile = fopen("input.txt", "r");
countConsonants(myFile);
return 0;
}
Input file:

Output:


•The multiplication operator works by summing some value, x, by another value, y. Write a function...
Please Use C++ for coding
. . Note: The order that these functions are listed, do not reflect the order that they should be called. Your program must be fully functional. Submit all.cpp, input and output files for grading. Write a complete program that uses the functions listed below. Except for the printodd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention...
Note: The order that these functions are listed, do not
reflect the order that they should be called. Your program must be
fully functional. Submit all .cpp, input and output files for
grading.
Write a complete program that uses the functions listed below.
Except for the printOdd function, main should print the results
after each function call to a file. Be sure to declare all
necessary variables to properly call each function. Pay attention
to the order of your function...
Write a function in the C++called summary that takes as its parameters an input and output file. The function should read two integers find the sum of even numbers, the sum of odd numbers, and the cumulative product between two values lower and upper. The function should return the sum of even, odd, ad cumulative product between the lower and upper values. Please write program in C++.
Write a complete program that uses the functions listed below. Except for the printOdd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention to the order of your function calls. Be sure to read in data from the input file. Using the input file provided, run your program to generate an output file. Upload the output file your program generates. •Write a...
Write a function called productEven that takes as its parameter an input file. The function should read two integers and calculate the total product of only even numbers between them. Return the answer to the calling function. c++ program
please write program in C++ Write a function called productEven, that takes as its parameter an input file. The function should read two integers and calculate the total product of only even numbers between them. Return the answer to the calling function. please write the program in C++
Lab 1 Q1. Write a Python program with the following function building block. •All input values are to be taken fro m the user. •Ensure to check for possible error cases like mismatch of data type and input out of range, for every function. Function 1: countVowels(sentence) – Function that returns the count of vowels in a sentence. Function 2: Sum of all even numbers between two numbers, identify number of parameters Q2. Write a Python program that reads a...
Write a C++ program that will count the number of words and vowels in a sentence. Create a bool function called isVowel that accepts a character as a parameter and returns a true if it’s a vowel (aeiou) and false otherwise. Create an int function named countVowels that will accept a string variable as a parameter and will return the number of vowels in it. Call the isVowel function as part of this process. Write an int function named countWords...
Write a function that takes an array of integers as an argument and returns a value based on the sums of the even and odd numbers in the array. Let X = the sum of the odd numbers in the array and let Y = the sum of the even numbers. The function should return X – Y The signature of the function is: int f(int[ ] a) Examples if input array is return {1} 1 {1, 2} -1 {1,...
Using python
Question 13 (20 points) Write a function named Linestats that finds the number of consonant and vowel letters on each line of a file and writes those statistics to a corresponding line of a new file, separated by a space. Definitions: A vowel letter is one of a, e, i, o, u, along with the corresponding uppercase letters..A consonant letter is not a vowel letter. The function linestats takes two parameters: 1. inFile, a string, the name of...