Question

write an algorithm ( pseudocode in c) which counts the number of element larger than P...

write an algorithm ( pseudocode in c) which counts the number of element larger than P bit smaller than Q.

Homework Answers

Answer #1

PSEUDOCODE :

Step1:Declare an array of size 10.

int arr[10];

Step2:Declare variables p and q.

int p,q;

step 3:Declare and initialise count to 0.

int count=0;

step4.Get all elements of array from user.

for(int i=0;i<10;i++){

scanf("%d",&arr[i]); }

step5:Repeat 10 times.

a)check element is greater than p and less than q.

if((a[i]>p)&&(a[i]<q));

b)if condition is true,increment value of count,

count++;

c)else continue.

step 6:end loop.

step 7:Print count.

Step:8:END

  

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write an iterative algorithm in Java-like pseudocode for printing a singly linked list in reverse in...
Write an iterative algorithm in Java-like pseudocode for printing a singly linked list in reverse in O(N) time. You can use as much extra space as you need. The original list pointers CAN NOT BE MODIFIED. State in big-O notation how much extra space is used by this algorithm. Write another iterative algorithm in Java-like pseudocode for printing a singly linked list in reverse using O(1) extra space. The original list pointers CAN NOT BE MODIFIED. This algorithm can have...
Write a C++ recursive function that counts the number of nodes in a singly linked list....
Write a C++ recursive function that counts the number of nodes in a singly linked list. (a) Test your function using different singly linked lists. Include your code. (b) Write a recurrence relation that represents your algorithm. (c) Solve the recurrence relation using the iterating or recursive tree method to obtain the running time of the algorithm in Big-O notation.
write your prediction for p^n where n is a number larger than 512. Use 8 decimal...
write your prediction for p^n where n is a number larger than 512. Use 8 decimal places in prediction, where necessary. Side note P= the matrix below 0.1 0.8 0.1 0.7 0.1 0.2 0.1 0.5 0.4
1. Given an n-element array A, Algorithm X executes an O(n)-time computation for each even number...
1. Given an n-element array A, Algorithm X executes an O(n)-time computation for each even number in A and an O(log n)-time computation for each odd number in A. What is the best-case running time of Algorithm X? What is the worst-case running time of Algorithm X? 2. Given an array, A, of n integers, give an O(n)-time algorithm that finds the longest subarray of A such that all the numbers in that subarray are in sorted order. Your algorithm...
If your company's beta is larger (smaller) than S&P 500's, then would you expect that your...
If your company's beta is larger (smaller) than S&P 500's, then would you expect that your company's S.D. also has to be larger (smaller) than S&P 500's? Why or why not?
Write the function has duplicate() which takes as input a vector v and outputs true if...
Write the function has duplicate() which takes as input a vector v and outputs true if there is a re- peated element in v and false if there is no repeated elements. Below is the algorithm which you should implement. default output is 0 for elt1 in v: for elt2 later in v than elt1: if elt1==elt2, make output 1, break, end end end Checking if elt1==elt2 counts as one step. Setting the output value also counts as one step....
If doubling the smaller standard deviation results in a number less than the larger deviation, is...
If doubling the smaller standard deviation results in a number less than the larger deviation, is pooling appropriate?
Write a short script filecount.sh that counts the total number of files in the current directory...
Write a short script filecount.sh that counts the total number of files in the current directory with names matching a specified pattern, and print out this number to screen. For example, bash filecount.sh *.txt should return the number of .txt files found in the current directory, while bash filecount.sh p*.txt should return the number of text files with names starting with p.
Design an algorithm (write in pseudo code) which takes less than Θ(n) to search an entry...
Design an algorithm (write in pseudo code) which takes less than Θ(n) to search an entry (name of a person) in a telephone directory. Analyze this algorithm for its worst-case input situation. Make necessary assumptions to simplify your comparisons. If you don’t know what is a telephone directory, check out this link https://en.wikipedia.org/wiki/Telephone_directory
A positive real number is 2 less than another . When 4 times the larger is...
A positive real number is 2 less than another . When 4 times the larger is added to the square of the smaller, the result is 49. Find the numbers.