Question

In: Computer Science

C programming language. **I am aware that I am only supposed to ask one question so...

C programming language.

**I am aware that I am only supposed to ask one question so if you cant do all of this could you please do part 3? thank you!

This lab, along with your TA, will help you navigate through applying iterative statements in C. Once again we will take a modular approach to designing solutions to the problem below. As part of the lab you will need to decide which C selection structure and iterative structure is best suited for a particular function. You will have the option to use "if", "switch", "while", "do-while", and/or "for" statements for the below problem.

Labs are held in a “closed” environment such that you may ask your TA questions. Please use your TAs knowledge to your advantage. You are required to move at the pace set forth by your TA. Have a great time! Labs are a vital part to your education in CptS 121 so work diligently.

Tasks:

1.    a. With your team, write a program that reads in each of the integer values in a file and determines if the sum of the integers is prime. Use functions where appropriate!

     b. Determine if the sum of the individual digits, in the sum of the integers, is prime. Use functions where appropriate!

2. With your team, write a program that determines the factorial of n, represented n!, where n is entered by the user. Make sure that your program checks to see if n is greater than or equal to 0. As long as n is negative your program should continue to prompt for another value for n. Recall 0! is equal to 1 and 1! is also equal to 1. The factorial of a number such as n! is equal to n * (n – 1) * (n – 2) *… * 1. Use functions where appropriate!

3. Write a program that determines the Fibonacci number for the nth term. Recall, the first Fibonacci number is 0 and the second Fibonacci number is 1. The next number in the sequence is always determined by the sum of the previous two terms or numbers in the sequence. Fib (n) = Fib (n-1) + Fib (n-2). The n value should be entered by the user. Use functions where appropriate!

4. Write a program that generates a random number between -100 to 100 and requires that the user guesses which number was generated. If the user guesses too high, then the program should say so. If the user guesses too low, then the program should say so again. The program should continue to loop until the user guesses the correct number. If the user guesses a number outside the range of -100 to 100, then the program should just prompt the user to re-enter a number without indicating if the guess was too high or too low. Keep track of the total number of guesses taken by the user. Use nested loops to solve this problem. Use functions where appropriate!

Solutions

Expert Solution

Here is the solution of question 3

here is the code

#include <stdio.h>
void fibbonacci(int n)
{
int prev=0,next=1,tem,i;
if (n==1)
{
printf("1 fibbonacci number is %d",0);
}
else if (n==2)
{
printf("2 fibbonacci number is %d",0);
}
else
{
for(i=2;i<n;i++)
{
tem=prev+next;
prev=next;
next=tem;
  
}
printf("%d fibbonacci number is %d",n,next);
}
}

int main()
{
int n;
printf("Enter value of n:");
scanf("%d",&n);
fibbonacci(n);
return 0;
}


Related Solutions

C programming language. **I am aware that I am only supposed to ask one question so...
C programming language. **I am aware that I am only supposed to ask one question so if you cant do all of this could you please do part 2? thank you! This lab, along with your TA, will help you navigate through applying iterative statements in C. Once again we will take a modular approach to designing solutions to the problem below. As part of the lab you will need to decide which C selection structure and iterative structure is...
IN PROGRAMMING LANGUAGE C -I am trying to alphbetize a string in descending or to EX...
IN PROGRAMMING LANGUAGE C -I am trying to alphbetize a string in descending or to EX INPUT: B C D A OUTPUT: D C B A #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main(int argc, char*argv[]) {         int MAX = 100000;         int i =0;         int k =0;         int j =0;         char array[MAX];         char split[] = " ,.-!?()0123456789";         int n = 0;         char second[MAX];         printf("Please enter in a String: ");...
I am building a game in C programming language where I need to add objects of...
I am building a game in C programming language where I need to add objects of various length into a game board. The game board is 8X8 and we must account for the boundaries for the board and not go over them with our objects. The boards upper left corner is at 0x0 and we must return 1 if it fits and -1 if it does not fit. I have the following 2 functions to start with: ```int add_object_vert(int r,...
I thought for this type of question I am supposed to make a chart with the...
I thought for this type of question I am supposed to make a chart with the inventory, purchases, sales, etc., but instead, these questions are throwing me off for the little understanding I have on this new topic... Kayla Company uses the perpetual inventory system and the LIFO method. The following information is available for the month of June: June 1 Beginning inventory 200 units @ $5 12 Purchase on account 400 units @ $6 15 Sales on account 440...
I am not aware of GR, but due to curiosity i have a question in my...
I am not aware of GR, but due to curiosity i have a question in my mind. Please let me know if it is inappropriate to ask here. My question is about singularity. I am under the assumption that singularity means in mathematical terms equivalent to a discontinuity in a function. My question is what type of discontinuity are the ones corresponding to Penrose-Hawking singularity theorems and also to the the naked singularity ? by type i mean removable (left...
I am supposed to study this question and answer because it is a possible test question,...
I am supposed to study this question and answer because it is a possible test question, and this is the only one I am unable to answer when it comes to the disadvantages and advantages of a builder. Disadvantages and advantages to a skilled worker - Describe in as much detail, the key components of the Davis-Bacon Act. What are its advantages and disadvantages to a builder? To a skilled worker?
Using (C programming language) Create a health monitoring program, that will ask user for their name,...
Using (C programming language) Create a health monitoring program, that will ask user for their name, age, gender, weight, height and other health related questions like blood pressure and etc. Based on the provided information, program will tell user BMI, blood pressure numbers if they fall in healthy range or not and etc. Suggestions can be made as what should be calorie intake per day and the amount of exercise based on user input data. User should be able to...
You are using ONLY Programming Language C for this: In this program you will calculate the...
You are using ONLY Programming Language C for this: In this program you will calculate the average of x students’ grades (grades will be stored in an array). Here are some guidelines to follow to help you out: 1. In your program, be sure to ask the user for the number of students that are in the class. The number will help in declaring your array. 2. Use the function to scan the grades of the array. To say another...
In C programming, I am trying to search for the names of people that in this...
In C programming, I am trying to search for the names of people that in this DOISigned.txt file, however I am having trouble getting the first and last names of the multiple people named john, my current code only searches for John once and then it terminates,here is my current code #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> #include <stdlib.h> #define BUF_SIZE 0x3000 char buf[BUF_SIZE]; int main() {    char* inputFile = "DOISigners.txt";    FILE* fp;    fp = fopen(inputFile, "r");...
Only Program in C for this. No other programming language is allowed. Using a function, we...
Only Program in C for this. No other programming language is allowed. Using a function, we will add a range of values of an array. The range is going to be determined by the user. In this example, if you put the following array down as: 1.5 -5.6 8.9 4.6 7.8 995.1 45.1 -5964.2 … and the user tells you to add from the 3rd element to the 6th element, your program is going to need to add the values:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT