please do upvote.If you have any problem do comment and i shall be happy to help you.Thanks for using HomeworkLib.
Note: I have answered the first question only as per HomeworkLib's policy
-----------------------------
//tools.h
unsigned long long fac_rec(unsigned int x);
unsigned long long fac(unsigned int x);
unsigned long long fib_rec(int n);
unsigned long long fib(int n);
-----------------------------
//tools.c
#include "tools.h"
unsigned long long fac_rec(unsigned int x)
{
if (x == 1) //factorial of 1 is 1
{
return 1;
}
else
{
unsigned long long answer =
fac_rec(x - 1); //calculate factorial of previous number
return x *answer;
}
}
unsigned long long fac(unsigned int x)
{
int a;
int answer = 1;
//calculate factorial of x using loop
for (a = x; a > 1; a--)
{
answer = answer * a;
}
if (x == 0)
{
answer = 1;
}
return answer;
}
unsigned long long fib_rec(int n)
{
if (n == 0)
{
return 0;
}
if (n == 1)
{
return 1;
}
//calculate fibonacci of previous two numbers
unsigned long long a = fib(n - 1);
unsigned long long b = fib(n - 2);
return a + b;
}
unsigned long long fib(int n)
{
int old = 1;
int present = 1;
int upcoming = 1;
int a = 0;
//calculate fibonacci of nth number using
loop
for (a = 3; a <= n; ++a)
{
upcoming = present + old;
old = present;
present = upcoming;
}
return upcoming;
}
---------------------
//final_main.c
#include<stdio.h>
#include<conio.h>
#include"tools.h"
void main()
{
int num = 0;
long result = 0;
while (1)
{
//get input
printf("enter a positive int
between 0 and 10 inclusive: ");
scanf_s("%d", &num);
if (num < 1)
{
break;
}
//outputs
result=fac_rec(num);
printf("result of fac_rec : %ld
\n", result);
result = fac(num);
printf("result of fac : %ld \n",
result);
result = fib_rec(num);
printf("result of fib_rec : %ld
\n", result);
result = fib(num);
printf("result of fib : %ld \n",
result);
}
}
----------------------------------

*********C Language******* Write a file final_main.c 4. Inside main(void): Write a loop that oops until the...
Write a program that prompts for a sentence and calculates the number of uppercase letters, lowercase letters, digits, and punctuation. Output the results neatly formatted and labeled in columns. how I can make this program in a more simple way. # get user input user_string = input("Enter a sentence: ") # create and initialize variables upper_case = 0 lower_case = 0 digits = 0 spaces = 0 punctuations = 0 x = len(user_string) #loop conditions and increment for i in...
Write a C++ program that repeatedly reads lines until an EOF is encountered. As each line is read, the program strips out all characters that are not upper or lower case letters or spaces, and then outputs the line. Thus, the program acts as a filter and issues no prompt. There are many ways this program could be written, but to receive full credit, you must observe the following: Place your code in a file called filterChars.cpp. The program should...
Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence. Your program should prompt for an integer input n from the user. The program should call a recursive function to compute the nth fibonacci number. Your program must follow programming convention. You should submit program and screenshot of output in a single word/pdf file. You should use following recursive definition of fibonacci function: fib(0) = 0 fib(1) = 1 fib(n) = fib(n-1) +fib(n-2)
#include <stdlib.h> #include <stdio.h> #include "main.h" #define MAX_NUM_LENGTH 11 void usage(int argc, char** argv) { if(argc < 4) { fprintf(stderr, "usage: %s <input file 1> <input file 2> <output file>\n", argv[0]); exit(EXIT_FAILURE); } } /* This function takes in the two input file names (stored in argv) and determines the number of integers in each file. If the two files both have N integers, return N, otherwise return -1. If one or both of the files do not exist, it...
Write an interactive program exam1 that loops Loop and asks the user at the end of the loop to continue or not Ask the user to enter an alphanumeric US phone number Read the line of text from the screen Check if the entered string is a valid phone number using isValid(Line) if it is valid number { call toNumeric(line) to convert it to digits print Line after conversion } bool isValid(char line[]) { //st must have 10 digits and...
What to do Write a C program that computes Pi with the approximation algorithm that I introduced in class. I want you to write the program in two different ways: The first version will add up the first 28284277 elements of the approximation series in a simple for loop. I ask you to put the code into a function with this signature: float get_pi_for(void); The second version will break out of a while loop depending on whether a pair of...
General Requirements . . . Write a program that reads letters from a file called "letters.txt". Your program will open the letters.txt file read in one character at a time For this assignment the test file will contain at least 30 letters, uppercase OR lowercase In your program you will change each letter (solution) to uppercase Use the function toupper in #include <ctype.h> You create a numerical version of the uppercase letter from the file . o Use int numberSolution...
Write a C program that computes Pi with the approximation algorithm that I introduced in class. I want you to write the program in two different ways: The first version will add up the first 28284277 elements of the approximation series in a simple for loop. I ask you to put the code into a function with this signature: float get_pi_for(void); The second version will break out of a while loop depending on whether a pair of adjacent elements (remember...
c++. please show screenshots of output
This project will continue to familiarize the student with using arrays. Store all the function proto-types in project11_funch and store all the functions in project11_func.cpp. Make sure you have proper header comments in each.h,.cpp file. When you run your program, your sample output should show your name. Your report should include the following: 1) project11_func.h 2) project11_func.cpp 3) project11.cpp 4) sample output Write the following functions: a) void fill_array_with_random_nums(int array(), int N): Fill array...
Program Description: (C++). Write a word search program that searches an input data file for a word specified by the user. The program should display the number of times the word appears in the input data file. In addition, the program should count and display the number of characters in the input data file that are not vowels. Your program must do this by providing the following functions : void processFile(ifstream &inFile, string &word, int &wordCount, int &nonVowelCount) ; void...