Question

In: Computer Science

In C programming, Thanks Write a program to determine which numbers in an array are inside...

In C programming, Thanks

Write a program to determine which numbers in an array are inside a particular range. The limits of the range are inclusive.

You have to write a complete "C" Program that compiles and runs in Codeblocks. (main.c)

1. Declare an array that can contain 5 integer numbers. Use as the name of the array your LastName.

2. Use a for loop to ask the user for numbers and fill up the array using those numbers.

3. Ask the user for the lower limit of the range.

4. Ask the user for the upper limit of the range.

5. Use a for loop to check all the numbers in the array and print the numbers inside the range.

The following is an example of how your program should look when you execute it:

Enter a number to store in the array: 10
Enter a number to store in the array: 90
Enter a number to store in the array: 145
Enter a number to store in the array: 94
Enter a number to store in the array: 97

Enter the lower limit of the range: 90
Enter the upper limit of the range: 99

The numbers in the range are: 90, 94, 97

Solutions

Expert Solution

main.c:
-------

#include <stdio.h>

int main()
{
    int karri[5];
    int lower, upper;
    for(int i=0;i<5;i++)
    {
        printf("Enter a number to store in the array:");
        scanf("%d",&karri[i]);
    }
    printf("\nEnter the lower limit of the range:");
    scanf("%d",&lower);
    
    printf("Enter the upper limit of the range:");
    scanf("%d",&upper);
    
    printf("The numbers in the range are:");
    for(int i=0;i<5;i++)
    {
        if(karri[i]>=lower && karri[i]<=upper)
            printf(" %d,",karri[i]);
    }
    printf("\b ");
    return 0;
}




Output:
-------
Enter a number to store in the array:10                                                                                         
Enter a number to store in the array:90                                                                                         
Enter a number to store in the array:145                                                                                        
Enter a number to store in the array:94                                                                                         
Enter a number to store in the array:97                                                                                         
                                                                                                                                
Enter the lower limit of the range:90                                                                                           
Enter the upper limit of the range:99                                                                                           
The numbers in the range are: 90, 94, 97

Related Solutions

Programming in C++ Write a program that prints the values in an array and the addresses...
Programming in C++ Write a program that prints the values in an array and the addresses of the array’s elements using four different techniques, as follows: Array index notation using array name Pointer/offset notation using array name Array index notation using a pointer Pointer/offset notation using a pointer Learning Objectives In this assignment, you will: Use functions with array and pointer arguments Use indexing and offset notations to access arrays Requirements Your code must use these eight functions, using these...
Programming In C Write a program that prints the values in an array and the addresses...
Programming In C Write a program that prints the values in an array and the addresses of the array’s elements using four different techniques, as follows: Array index notation using array name Pointer/offset notation using array name Array index notation using a pointer Pointer/offset notation using a pointer Learning Objectives In this assignment, you will: Use functions with array and pointer arguments Use indexing and offset notations to access arrays Requirements Your code must use these eight functions, using these...
In C programming: Write a program that initializes an array-of-double and then copies the contents of...
In C programming: Write a program that initializes an array-of-double and then copies the contents of the array into another arrays. To make the copy, use a function with array notation. This function takes two arguments the name of the target array and the number of elements to be copied. That is, the function calls would look like this, given the following declarations: double source[5] ={1.1, 2.2, 3.3., 4.4, 5.5}; double target1[5]; double target2[5]; copyarr(source, target1, 5);
Ruby programming Create a Ruby program which reads numbers, deposits them into an array and then...
Ruby programming Create a Ruby program which reads numbers, deposits them into an array and then calculates the arithmetic mean (otherwise known as the average), the median (that is, the number that splits the set of value in half with half being above and half being below the number), and the standard deviation (that is, the average of distance each number is from the mean then squared). Further information about these calculations can be found here: average: http://en.wikipedia.org/wiki/Average (add up...
C programming. Write a program that prompts the user to enter a 6x6 array with 0...
C programming. Write a program that prompts the user to enter a 6x6 array with 0 and 1, displays the matrix, and checks if every row and every column have the even number of 1’s.
Programming lang C++ Write a program that reads 10,000 words into an array of strings. The...
Programming lang C++ Write a program that reads 10,000 words into an array of strings. The program will then read a second file that contains an undetermined number of words and search the first array for each word. The program will then report the number of words in the second list that were found on the first list.
C++ programming language. Write a program that will read in id numbers and place them in...
C++ programming language. Write a program that will read in id numbers and place them in an array.The array is dynamically allocated large enough to hold the number of id numbers given by the user. The program will then input an id and call a function to search for that id in the array. It will print whether the id is in the array or not. Sample Run: Please input the number of id numbers to be read 4 Please...
in C++, Write a program that asks the user to enter 6 numbers. Use an array...
in C++, Write a program that asks the user to enter 6 numbers. Use an array to store these numbers. Your program should then count the number of odd numbers, the number of even numbers, the negative, and positive numbers. At the end, your program should display all of these counts. Remember that 0 is neither negative or positive, so if a zero is entered it should not be counted as positive or negative. However, 0 is an even number....
In C Programming, Thanks Many user-created passwords are simple and easy to guess. Write a program...
In C Programming, Thanks Many user-created passwords are simple and easy to guess. Write a program that takes a simple password and makes it stronger by replacing characters using the key below, and by appending "q*s" to the end of the input string. You may assume that the string does not contain spaces and will always contain less than 50 characters. i becomes ! a becomes @ m becomes M B becomes 8 o becomes . Ex: If the input...
Using the C Programming language, write a program that sums an array of 50 elements. Next,...
Using the C Programming language, write a program that sums an array of 50 elements. Next, optimize the code using loop unrolling. Loop unrolling is a program transformation that reduces the number of iterations for a loop by increasing the number of elements computed on each iteration. Generate a graph of performance improvement. Tip: Figure 5.17 in the textbook provides an example of a graph depicting performance improvements associated with loop unrolling. Marking:- Optimize the code for an array of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT