50% found this document useful (2 votes)
148 views3 pages

Array Programming Exercises

The document contains questions related to arrays and structures in C programming. It asks to write programs that: 1) Input integers into an array and count prime numbers. 2) Input student roll numbers and marks into two arrays and display the highest marks. 3) Use four arrays to store numbers, squares, cubes and sums and display the total sum. 4) Input employee names, salaries, and check if annual salary exceeds threshold to display tax message. The document then asks similar questions related to structures, including storing player records, employee records, income tax calculations, and book ordering details.

Uploaded by

Ahmad Khalid
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
148 views3 pages

Array Programming Exercises

The document contains questions related to arrays and structures in C programming. It asks to write programs that: 1) Input integers into an array and count prime numbers. 2) Input student roll numbers and marks into two arrays and display the highest marks. 3) Use four arrays to store numbers, squares, cubes and sums and display the total sum. 4) Input employee names, salaries, and check if annual salary exceeds threshold to display tax message. The document then asks similar questions related to structures, including storing player records, employee records, income tax calculations, and book ordering details.

Uploaded by

Ahmad Khalid
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Chapter -Array

Q1: Write a program that inputs ten integers in an array and counts all prime numbers entered by the user. The program finally displays total number of primes in array. Q2: Write a program that uses two arrays to store the roll number and marks of student. It inputs roll number and marks of five students and stores them in corresponding elements of the arrays (for example, if roll number 1 is stored in rno[0] then his marks must be stored in marks[0] and so on.) the program finally displays the roll number and marks of students with highest marks. Q3: Write programme that for arrays numbers, squares, cubes and sums each consisting of ten elements. The numbers array stores the values of its indexes, the squares array stores the squares of its indexes, the cubes array stores the cubes of its indexes and sum of array stores the sum of corresponding indexes of three arrays. The programme should display the values of sums of array and total of all values in sum array. Q4: Write programme that inputs the names and monthly salaries of ten employees. The programme checks annual salaries of each person. If annual salary is greater than or equal to rupees 2,50000/ then prints name, salaries and a message tax to be paid else it prints name, salaries and a message no tax. Q5: Write a programme that inputs ten integers in an array, it displays the number of occurrences of each number in the array as follows 3 is stored four times in the array. 1 is stored one time in the array Q6: Write a programme that inputs the marks of ten students. The programme displays the number of students in each grade. The criteria is as follows 80 or above 60-79 40-59 Below to 40 A B C F

Q7: Write a programme that use three arrays mango, orange and banana to store the number of fruits purchased by customer. The programme inputs the number of mangoes, oranges and bananas to be purchase by customer and stored them in crosssponding arrays. The finally display the total bill of each customer according to the following price Rs. 20 per mango Rs. 10 per orange Rs. 5 per banana The output should appear as follows Customer number 1 Q8: Write a programme that inputs ten floating points number in an array. It displays the values which are greater than average value of array. Q9: Write a programme that uses of two dimensional arrays to initialize the scores of the students. The students are arranged in five rows with five students in each row. The programme inputs the row number and student number in that row and displays the score of the student. mangoes 5 oranges 10 bananas 12 total bill 260

Chapter- Structures
Q1: Write the programme that declares the structure to store the distance covered by player along with the minutes and seconds taken to the covered the distance. The programme should input the records of two players and then display the record of the winner. Q2: Write a programme that declared the structure the code number, salaries and grade of an employee. The programme refines two structure variables, inputs records of two employees and then display the record of the employee with more salary. Q3: Write a programme that declares a structure to store income, tax rate and tax of a person.

The programme defines an array of structure to store the record of 5%. It input income and tax rate of 5% and then display the tax payable. Q4: Write a programme that declares a structure book to store book id, book name and price. It declares another structure order that contains order id and array of the book of length 5. The programme should define a variable of type order and input the values from users. The programme finally displays the values. _____________________________________________________________

Common questions

Powered by AI

Using two-dimensional arrays allows for efficient storage and retrieval of student scores by organizing data in rows and columns, where each row represents a set of students, and scores are accessed via indices. Advantages include easy indexing and matrix-like data manipulation, which is intuitive for grids. However, this approach can become inefficient with sparse data and doesn't support dynamic resizing, which can lead to wasted memory if the pre-defined array size does not fit the actual data .

The program declares a structure for books and another for orders, which includes an array of books. It allows input and management of book details for each order. Challenges include ensuring data consistency, avoiding array overflow, and efficiently managing lists and arrays of complex structures without causing memory leaks or synchronization issues during concurrent accesses .

The program compares each student's marks against predefined boundaries: 80 or above is 'A', 60-79 is 'B', 40-59 is 'C', and below 40 is 'F'. The benefit of categorizing marks into grades includes simplified aggregation of student performance, easier understanding for stakeholders, and standardization of evaluations which is helpful for large-scale educational analytics .

The program defines a structure to store each player's covered distance, minutes, and seconds. It inputs the records for two players and calculates their performance. Comparing the distances covered within the time constraints identifies the winner. Such programs are valuable in sports analytics for performance evaluation, optimizing training loads, and strategizing based on top athlete performances .

The program calculates the average of the array by summing all elements and dividing by the count. It then iterates through the array to identify and print elements greater than this average. This method is useful in data analysis, particularly in outlier detection and performance assessment, where elements deviating significantly from the average are of interest .

A program can count the number of prime numbers from ten integers by iterating through each number in the array, checking if each number is greater than 1 and has no divisors other than 1 and itself. The program increments a counter for each number that satisfies these conditions. Identifying prime numbers is significant in various fields such as cryptography, number theory, and for optimizing algorithms which rely on prime factorization .

The program uses three arrays to store the quantities of mangoes, oranges, and bananas purchased. It multiplies the quantities by their respective prices (Rs. 20 per mango, Rs. 10 per orange, Rs. 5 per banana) to calculate individual totals for each fruit type and sums these totals for the overall bill. This utility serves in e-commerce platforms and shop management systems where quick, accurate price calculations are often necessary .

The program calculates the annual salary for each employee and checks if it exceeds a threshold of rupees 2,50000/. Employees with salaries above this threshold are flagged for tax payment. This approach is vital in payroll systems to automate compliance with tax requirements, ensuring that high-earning employees are reported for tax collection, thereby facilitating accurate tax filings .

The program declares a structure that holds employee details including code number, salary, and grade. By defining two variables of this structure, it inputs each employee's salary and compares them to determine the higher salary by using conditional statements. This application is practical in payroll systems where salary comparisons are necessary for bonuses and promotions .

The program counts occurrences of each integer in an array using another array as a count tracker. Each time a number appears, its corresponding count is incremented. This functionality is practical in statistical analysis and data mining, where understanding the frequency of elements is critical for patterns and trend detection .

You might also like