Python Program
Write a program to print the following, Given a word W and pattern P, you need to check whether the pattern matches the given word.The word will only contain letters(can be Uppercase and Lowercase). The pattern can contain letters, ? and *.
? : Can be matched with any single letter.
* : Can be matched with any sequence of letters (including an empty sequence).
If the pattern matches with the given word, print True else False.
Sample Input1
3
Hello *l?
Hell He?ll
Hell ?*
Sample Output1
True
False
True
Sample Input1
3
Hello Hell*
Hell He*ll
Hell hell*
Sample Output1
True
True
False
An election is contested by five candidates. The candidates are numbered 1 to 5 and a voting is done by marking the candidate number in a ballot paper. Write a C++ program to read the ballot and count the votes cast for each candidate using an array variable count. In case, a number read is outside the range 1 to 5 the ballot should be considered as a 'spoilt ballot', and the program should also count the number of spoilt ballots
An election is contested by five candidates. The candidates are numbered 1 to 5 and a voting is done by marking the candidate number in a ballot paper. Write a C++ program to read the ballot and count the votes cast for each candidate using an array variable count. In case, a number read is outside the range 1 to 5 the ballot should be considered as a 'spoilt ballot', and the program should also count the number of spoilt ballots
The function Power, which raises the integer number x to the power n, can be defined recursively as follows:
Power(x, n) = 1 for n = 0
Power(x, n) = x * Power(x, n-1) for n > 0
(i) Using the above definition write the recursive function Power(x, n) in C.
(ii) Rewrite the recursive function Power(x, n) in an iterative form.
(iii) Write the main function and test the above-written functions. Note: You can write one program and test the functions or you may write two separate programs for each part (i) and (ii)
Write a program that dynamically allocates an array large enough to hold a user-defined number of test
scores. Once all the scores are entered, the array should be passed to a function that sorts them in
ascending order. Another function should be called that calculates the average score. The program
should display the sorted list of scores and averages with appropriate headings. Use pointer notation
rather than array notation whenever possible.
Input Validation: Do not accept negative numbers for test scores.
Example
Enter the number of test scores: 4
Enter each test score:
Test#1: 34
Test #2: 73
Test #3: 22
Test #4: 89
Sorted test scores:
Test #1: 22
Test #2: 34
Test #3: 73
Test #4: 89
Average = 54.5
A 1D binary character array is given to you in file “task1.txt”. You are required to find out maximum
consecutive ones in the array.
Note: Read the file and find the exact length of data in a separate function. Use that size to create a
dynamic integer array using pointers. Then, read the file again and insert data into this dynamic array of
exact calculated size. Then You are required to find out maximum consecutive ones in the array.
task1.txt
11010101111110110111010
Expected output:
- maximum consecutive ones are: 111111
- Starting index is: 7
- Length is: 6
Using C# and Visual Studio, design and implement a standalone command line application that can be used to calculate the average grade for a student doing four course:
1. Create a class called Grading to do the following:
2. In Grading class, the student must enter their name, Surname, StudentId (Use getters and setters for all variables)
3. In Grading class, the student must capture his/her final marks for PROG6211, CLDV6211, DBAS6211, and SAND6211, the marks must be captured into an array
4. In Grading class, Create a method that takes the array of marks as a parameter and returns a calculated average for all marks
5. Create another class Called FinalGrading that contain a method with a switch statement to grade the average returned mark.
a. Average mark >=75 => Frist Class
b. Average mark between 74% and 65% => Second class
c. Average mark between 50% and 64% => Third class
d. Average mark less than 50% => Fail
given an integer number n as input.write a program to print the hollow right angled traingular pattern of n lines.(note:there is a space after each asterisk(*) character)
10. Consider a two-dimensional array Marks[10][5] having its base address as 2000 and the
number of
bytes per element of the array is 2. Now, compute the address of the element, Marks[8][5],
assuming that the elements are stored in row major order.
Take a real-world scenario of inheritance and implement it in C++ program. Your program should consist of the following:
1. Use Constructors and appropriate access modifier 2. List and draw Base class and Derived class 3. Show polymorphism (function overriding and function overloading) 4. Multiple inheritance 5. Put the user’s data into a file and display a data from a file to the user.
6. Implement Abstract class and interface