Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Assignment 3: Array, Iteration, and Case Control: C Programming Demo Assignments 1. Write a program to print all prime numbers from 1 to 300. (Use nested loops, break and continue) 2. Find 2nd largest number from an array of general size n. (You may do this on a fixed size array with just an 'if then else' branching tree.) Exercise Assignments: B.1.3.1 Write a C program to implement the Bubble Sort algorithms using array on a set of N numbers. B.1.3.2 Write a program to display Pascal's triangle. Pascal's triangle represents the binomial coefficients. The first few rows of Pascal's triangle are displayed below. Observe how a row is related to the row above it. Extra Point: How many arrays did you use for the problem 2? Try solving the problem with just one array if you have used more. B.2.3.1 Write a program to compute the frequencies of all distinct numbers that appear in the array of size N. Read N and the actual numbers in the array from the keyboard before you compute the frequency. Also find out how many of them are positive, how many are negative, how many are even and how many odd. B.2.3.2 Given an array of integers of size n, find out if the numbers in the array appear in a palindromic order. A palindrome is a sequence that reads the same when you flip it. For example, 121 is a palindrome, 3 is a palindrome, and 234432 is also a palindrome B.3.3.1 Write a program which to find the grace marks for a student using switch. The user should enter the class obtained by the student and the number of subjects he has failed in. • If the student gets first class and the number of subjects he failed in is greater than 3, then he does not get any grace. If the number of subjects he failed in is less than or equal to 3 then the grace is of 5 marks per subject. • If the student gets second class and the number of subjects he failed in is greater than 2, then he does not get any grace. If the number of subjects he failed in is less than or equal to 2 then the grace is of 4 marks per subject. • If the student gets third class and the number of subjects he failed in is greater than 1, then he does not get any grace. If the number of subjects he failed in is equal to 1 then the grace is of 5 marks per subject B.3.3.2 Given two sorted arrays of sizes m and n, write a program that merges the two into another array of size m + n such that this new array also remains sorted. Extra Problem 1: Write a program to produce the following output: Extra Problem 2: Print a triangle of '*'s of height 'r' rows. Now modify your program to print it upside down of given size 'r', where r represents the no. of rows in the triangle.