Write a program that does the following:
1. Initialize the variables.
2. Prompt the user to enter 20 numbers.
3. For each number in the list:
a. Get the next number.
b. Output the number (echo input).
c. If the number is even: {i. Increment the even count. ii. If the number is zero, increment the zero count. }otherwise, Increment the odd count.
4. Print the results.
1. You can initialize the variables zeros, evens, and odds when you declare them.
2. Use an output statement to prompt the user to enter 20 numbers.
3. For Step 3, you can use a for loop to process and analyze the 20 numbers.
In pseudocode, this step is written as follows: for (counter = 1; counter <= 20; counter++) { a. get the number; b. output the number; c. switch (number % 2) //check the remainder { case 0: increment the even count; if (number == 0) increment the zero count; break; case 1: case -1: increment the odd count; }//end switch }//end for 4. Print the result. Output the values of the variables zeros, evens, and odds.
Write a program that does the following:
8. a. if (nthFibonacci == 1)
the desired Fibonacci number is the first Fibonacci number.
Copy the value of previous1 into current.
b. else if (nthFibonacci == 2)
the desired Fibonacci number is the second Fibonacci number.
Copy the value of previous2 into current.
c. else calculate the desired Fibonacci number as follows:
Since you already know the first two Fibonacci numbers of the
sequence, start by determining the third Fibonacci number.
i. Initialize counter to 3, to keep track of the calculated
Fibonacci numbers.
ii. Calculate the next Fibonacci number, as follows:
current = previous2 + previous1;
iii. Assign the value of previous2 to previous1.
iv. Assign the value of current to previous2.
v. Increment counter.
9. Append the nth Fibonacci number to outputString. Notice that
the nth Fibonacci number is stored in current.
10. Display the output dialog box showing the first two and the nth Fibonacci
numbers.
The Gaussian distribution also known as the Normal distribution, is given by the following
equation:
𝑦(𝑥) = 𝑒𝑥𝑝 −(𝑥−𝜇)^2/2𝜎2
where parameter 𝝁 is the mean and 𝝈 the standard deviation.
(i) Write a MATLAB code to create a 1000 point Gaussian distribution of random numbers
having 𝜇 = 0 and 𝜎 = 1. (20)
(ii) Plot this distribution. (10)
(iii) Prove that the full width–half maximum (FWHM), of the above distribution is given by :
FWHM = 2𝜎√2ln 2 (10)
(iv) Write a program that estimates the FWHM from your data/graph. (10)
An alternative implementation of singly linked list is to create a structure of two external
pointers for the list, which contains both head and tail pointers.(( )* )
1
i ThoughtNumber MaximumNumber ThoughtNumber ThoughtNumber
n
i
100 *100
struct list {
nodeptr head;
nodeptr tail;
};
These pointers points to the first and the last elements of the list. Thus, the cost of
inserting a new element at end and deleting from the end of the list will be optimized to
O(1). Therefore, considering the given specification, write a C++ program which
implements the necessary operations for both unsorted and sorted list.
I. For unsorted list
Insertion of new element at head and at end
Deletion of an element from head, end and any element which mentioned with
key
Search
II. For sorted list
Insertion of new element at its proper position
Deletion of an element from head, end and any element which mentioned with
key
Search
// Lab: Binary Search (find errors)
// Written by:
#include <iostream>
#include <cstdlib>
using namespace std;
int binarySearch(const int array[], int numElems, int value);
int main() {
int list[100] = {5, 5, 8, 8, 8, 8, 9, 8, 9, 9, 10};
int length = 11;
for (int i = 0; i < length; i++) {
cout << list[i] << " ";
}
cout << endl;
for (int i = 0; i < 2 * length; i++) { // SEARCH 2 * length times
int target = rand() % 5 + 5; // generate a random target within the range 5 to 10
int location = binarySearch(list, length, target);
if (location = - 1)
cout << target << " NOT found!" << endl;
else
{
// print a range: from index A to Z, inclusive!
int z = location + 1;
while( z < length && list[z] == list[location] )
z++;
z--;
: Write a program to take input for n book records from user and write those book records in a file named: ”record”, whose price is less than INR 500 . Program should also perform random access in the file, after taking input for a particular record number to read and it should also perform random record overwriting after taking input of new record and the record number to overwrite. After overwriting record, display all records on the screen [Attributes of book: Book_id, Book_price, Book_name, Book_author_name]
Assign them (2, y) coordinates, where (0,0) is the upper-left corner of the map. In the example map above, we have lots of cells along the top edge; their coordinates are (0,0), (1,0), (2,0),(3,0),(4,0), (5,0),(6,0),... There are also quite a few along the left edge: (0,1),(0,2), (0,3), (0,4),(0,5).... The start point is at (4,0) and the end point is at (5,7).
I need python code of these coordinates its urgent .
How to convert basic data to user
defined data type? Explain
Andy has the word W and he wants to print the unique characters in the word in the order of their occurrence.write a program to help Andy print the unique characters as described above.
NOTE : consider lower and upper case letters as different
Input
The input is a single line containing the word W.
Output
The output should be a single line containing space separated characters.
Explanation
In the example, the word is MATHEMATICS
The unique characters in the given word are M, A, T, H, E, I, C, S, in the order of occurrence.so the output should be M A T H E I C S.
Sample Input1
MATHEMATICS
Sample Output1
M A T H E I C S
Sample Input2
banana
Sample Output2
b a n