CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

1. Junior Member
Join Date
Dec 2008
Posts
1

## Help Required!

I am internee in a company who has department for c++ programmers. They asked me to solve 20 Questions then we will give you a job, i have solve 14 but not being able to solve these 6, i will be very thankful to any one who solve my problem

Question 1)Write a program which consists of the functions average, sum, largest, smallest respectively. These functions should return back the average, sum, largest and smallest double values of the three dimensional double array array[5][7][9] in the main program from where they are called. This program must also tell the index of largest and smallest elements of array in the main function of the program. Properly use the menu using do while loop and name the functions used in the program. This program must use switch for different options. The largest and smallest values must be computed using ternary operator. Use of pointers and pointer arithmetic is MUST for the processing of the contents of this array.

Question 2)A website is hosting online radio. It has categories according to different genres of music. (POP, ROCK, GRUNGE, METAL). Each song has attributes such as Song Name, Artist, Genre and Duration. Properly use structures to solve the following tasks.
1. a. Write a function that prints the information of the songs of some specific genre given by user as input.
2. b. Write a function to retrieve information of all songs performed by a specific artist.
3. c. Write a function that prints information of a song searched by its name.

Question 3Question3:
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining. Assume that there are not more then 450 students in the college.
1. a. Write a function to print names of all students who joined in a particular year.
2. b. Write a function to print the data on a student whose roll number is given.

Question 4(The Sieve of Eratosthenes) A prime integer is any integer that is evenly divisible only by itself and 1. The Sieve of Eratosthenes is a method of finding prime numbers. It operates as follows:
1. a. Create an array with all elements initialized to 1 (true). Array elements with prime subscripts will remain 1. All other array elements will eventually be set to zero. You will ignore elements 0 and 1 in this exercise.
2. b. Starting with array subscript 2, every time an array element is found whose value is 1, loop through the remainder of the array and set to zero every element whose subscript is a multiple of the subscript for the element with value 1. For array subscript 2, all elements beyond 2 in the array that are multiples of 2 will be set to zero (subscripts 4, 6, 8, 10, etc.); for array subscript 3, all elements beyond 3 in the array that are multiples of 3 will be set to zero (subscripts 6, 9, 12, 15, etc.); and so on.
When this process is complete, the array elements that are still set to one indicate that the subscript is a prime number. These subscripts can then be printed. Write a program that uses an array of 1000 elements to determine and print the prime numbers between 2 and 999. Ignore element 0 of the array.

Question 5(Perfect Numbers) An integer is said to be a perfect number if the sum of its factors, including 1 (but not the number itself), is equal to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3. Write a function bool isPerfect(int p) that takes an integer p as argument and determines whether p is a perfect number. The function returns true if p is prime and false otherwise. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. Sample output: 6 28 …

Question 6: (Calculator) You have to implement a scientific calculator with added features in it. All built in and user defined functions for different tasks which might help in calculator must be incorporated in it. Have a look on Windows calculator and a scientific calculator to better get some idea. Function overloading must be there in it as well as discussed previously for different tasks.

Edit by admin: no contact info permitted on the forum, thank you

2. Junior Member
Join Date
Feb 2008
Posts
24

## Re: Help Required!

haha.. i thought that was the final assignment for course of C++ for telecom engineers at COMSATS institute of Information Technology Islamabad?

3. ## Re: Help Required!

We to not DO your work for you...Post your BEST efforts on each question.

4. Elite Member Power Poster
Join Date
Nov 2003
Location
Florida
Posts
12,518

## Re: Help Required!

Originally Posted by TheCPUWizard
We to not DO your work for you...Post your BEST efforts on each question.
But, but, but you don't understand. Help isn't just requested, it's required. We can't refuse.

5. Elite Member Power Poster
Join Date
Apr 1999
Posts
27,449

## Re: Help Required!

I am internee in a company who has department for c++ programmers. They asked me to solve 20 Questions then we will give you a job
If that's the case, I've got myself a job. How much do they pay, and can I work remotely if I don't live in the country?

Regards,

Paul McKenzie

6. Junior Member
Join Date
Dec 2008
Posts
4

## Re: Help Required!

I've done most of them before in different languages. Anyway good luck kiranpk, I'm sure that the company will be happy that you posted their questions for you to solve, on a public forum, with hoping that someone will solve them for you. Let us know how you go.

7. ## Re: Help Required!

I am internee in a company who has department for c++ programmers. They asked me to solve 20 Questions then we will give you a job
Lets think about this from other perspective. Maybe some guy put a good amount of time and effort for answering the question by himself. And you just want to get help from Proffesionals and maybe take the job from him..
The only thing which somes to my head is a word "loo..r"
PS: You dont deserve this job anyway......
Last edited by ulumulu; December 23rd, 2008 at 01:28 AM.

8. ## Re: Help Required!

In the terrible economic crisis, wether finding a job become such difficult?
Last edited by Fireseed; December 23rd, 2008 at 09:10 PM.

9. Junior Member
Join Date
Feb 2008
Posts
24

## Re: Help Required!

No no she lied.. its the assignment for the first semester course of C++ of BEng Telecom at one of the local universities at pakistan.. one of my friend asked me to make all these programs for him so thats how i know..

10. Senior Member
Join Date
Apr 2007
Location
Mars NASA Station
Posts
1,436

## Re: Help Required!

The truth is discovered. It's often very rude to laugh at newbie. Although i agree with all of you too but at least behave as professional as possible like THECPUWIZARD.

Attitude is also quite important. Therefore, i need to learn from THECPUWIZARD too.
Last edited by Peter_APIIT; December 24th, 2008 at 12:14 AM.

11. Elite Member Power Poster
Join Date
Nov 2003
Location
Florida
Posts
12,518

## Re: Help Required!

Originally Posted by Peter_APIIT
The truth is discovered. It's often very rude to laugh at newbie. Although i agree with all of you too but at least behave as professional as possible like THECPUWIZARD.

Attitude is also quite important. Therefore, i need to learn from THECPUWIZARD too.
IMHO, somebody asking for help cheating on a test deserves a little ridicule. This person isn't just a noob, it's somebody asking for help deceiving his/her employer or professor.

12. ## Re: Help Required!

Originally Posted by GCDEF
IMHO, somebody asking for help cheating on a test deserves a little ridicule. This person isn't just a noob, it's somebody asking for help deceiving his/her employer or professor.
And I agree with GCDEF....I guess I was just in a maganimous mood because of the holidays...

13. Junior Member
Join Date
Mar 2008
Posts
9

## Re: Help Required!

Well this exercise look pretty interesting for me to practice my C++ skill.

14. Elite Member Power Poster
Join Date
Apr 1999
Posts
27,449

## Re: Help Required!

Originally Posted by sotito
Well this exercise look pretty interesting for me to practice my C++ skill.
OK, let's try question 3.

1) Create a struct of student data:
Code:
```struct StudentData
{
std::string rollNumber;
std::string studentname;
// etc...
};```
2) Create an array of 450 students maximum.

3) Introduce an int variable that keeps track of the real number of students (up to 450).

4) Create a functor that takes a roll number on construction. This functor uses an overloaded operator (). The overloaded operator() takes a single StudentData passed in as a const reference. The operator() determines if the rollNumber of the passed-in StudentData is equal to the rollNumber that was stored on construction of the functor. If the rollNumbers are equal, the operator() prints out the results and returns true, else it returns false.

5) The main() program uses the STL for_each() algorithm, using an instance of the functor described in step 4) to print the names, and the array start and end as the first two parameters. Example:
Code:
```#include <algorithm>
#include <string>

StudentData allData[450];
//...
struct RollNumberFunctor
{
//...
};

int main()
{
int actual_number_of_students;
//...
std::string roll_number;
//...
RollNumberFunctor rnf(roll_number);  // assume that we have the roll number to search for
//...
// print out the rollnumbers that match rnf.
std::for_each( allData, /* you fill this in to complete the call correctly*/);
//...
}```
6) Similar steps (4 and 5) are used to print the students who enrolled in a particular year.

For a person good in C++, this should take less than 10 minutes. An expert who is a reasonably fast typist -- 5 minutes or less to solve.

Regards,

Paul McKenzie

15. Junior Member
Join Date
Mar 2008
Posts
9

## Re: Help Required!

Originally Posted by Paul McKenzie

For a person good in C++, this should take less than 10 minutes. An expert who is a reasonably fast typist -- 5 minutes or less to solve.

Regards,

Paul McKenzie
Wow wish i was that fast.....

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•