0% found this document useful (0 votes)
30 views

Lab 1 Tasks (Revision)

The document outlines 10 tasks for a lab assignment, including writing functions to: raise one number to the power of another; print a pattern of numbers and symbols; calculate even and odd numbers in an array; concatenate strings; find the sum and average of array elements; find minimum and maximum array values; analyze user ratings entered into an array; summarize ratings of issues from a survey stored in a 2D array; replace characters in a string; and extract the username from an email address.

Uploaded by

GHULAM MOHIUDDIN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Lab 1 Tasks (Revision)

The document outlines 10 tasks for a lab assignment, including writing functions to: raise one number to the power of another; print a pattern of numbers and symbols; calculate even and odd numbers in an array; concatenate strings; find the sum and average of array elements; find minimum and maximum array values; analyze user ratings entered into an array; summarize ratings of issues from a survey stored in a 2D array; replace characters in a string; and extract the username from an email address.

Uploaded by

GHULAM MOHIUDDIN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab 1 Tasks

1. Write a function that takes two numbers as argument and finds the value of one
number raised to the power of another.

2. Write a function to Print the following pattern

1*1
2**2
3***3
4****4
5*****5

3. Write a function that reads in 5 numbers; stores them in an array and calculates and the
number of odd and even numbers. If user enters 0, it should not be counted.

4. Write a function that concatenates two strings.

5. Write a function that sums the value of all elements in an array. Display the Average
also.

6. Write two functions to find the lowest and highest value from an array. Array should be
filled by user.

7. Write a function that Asks the user to enter the assessment of their telephone service.

• He should enter 1 for excellent Service


• He should enter 2 for Good Service
• He should enter 3 for Average Service
• He should enter 4 for Below Average Service
• He should enter 5 for poor Service

Take Input from 50 users and store in a 1 D array. Now calculate and display how
many users rated the system Excellent, Good, Average, Below Average and Poor.

8. The Internet and the web are enabling more people to interconnect, join a cause, voice
opinions, and so on. In this program, you’ll write a simple polling program that allows
users to rate five social-consciousness issues from 1 (least important) to 10
(most important).
Pick five causes that are important to you (e.g., political issues, global environmental
issues). Use a one-dimensional array topics (of type String) to store the five causes.
To summarize the survey responses, use a 5-row, 10-column two-dimensional array
responses (of type int), each row corresponding to an element in the topics array and
each column represents the responses given by a person.
(Responses will be taken from ten persons)
When the program runs, it should ask the user to rate each issue. Store the responses in
the two-dimensional array. Now the program should display a summary of the results,
including:

a) Show the average of the ratings for each issue.


c) Which issue received the highest point total? Display both the issue and the
point total.
d) Which issue received the lowest point total? Display both the issue and the
point total.

9. Write a function that replaces T with O in the String given below: (2.5)
WelcTme tT TutTrialspTint.cTm
Return the modified string to main.

10. Write a function that asks the user to enter an email address. Extract the username
from the email address and return it to main.
e-g if user enters [email protected] , the function should return “student”.

You might also like