Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

problem1)a) A function is defined on [0,∞) as follows:

1363_C function.jpg

prepare a C function to find out this function in the interval [0,M) where M is the maximum possible long double number. You can use an approximation for p in your function.

b) A life-insurance saleswoman earns commission for selling policies as follows:

• If the policy amount is ≤ Rs. 15,000, the commission is 0.4% of policy amount.

• If policy amount is ≥ Rs. 15,000 but less than or equal to Rs. 30,000, the commission is Rs. 60+0.6%  of the amount in excess of Rs. 15,000.

• If the policy amount is more than Rs. 30,000, the commission is Rs. 150 +0.8% of the amount in excess of Rs. 30,000.
prepare a C program that reads the amount of insurance sold and outputs the commission of the saleswoman.

problem2)a) What does the following program do? describe, line by line, starting from line 5, how it works.

1 #include
2 int main()
3 {
4 int i, k;
5 char * string = "To be or not to be.";
6 for (i = 1; * ++string;)
7 i++;
8 for (k = 1;k <= i; k++)
9 printf("%c",string[-k]);
10 return 0;
11 }

b) prepare a program that does the following:

i) Declares a struct that stores the name and age of a person.
ii) Uses typedef to name the struct as data.
iii) Declares a variable of type data , read the details of a person from the terminal using scanf() and stores it in the variable declared.
iv) Prints whether the age of the person is above 40 or below 40 using a function that takes data as  input and prints appropriate output.

problem3)a) The following program reads an unsigned long integer and prints its binary expansion. describe, line by line, starting from line 5, how it works.( Note: This program is written for a machine in which unsigned long is 4 bytes long. Also, you may have to append ‘L’ to the number you are entering.)

1 #include
2 int main()
3 {
4 unsigned long int i, j=1;
5 int k,a[33];
6 printf("Enter a natural number:\n");
7 scanf("%lu\n",&i);
8 for (k = 0; k<= 32;j*= 2,k++)
9 a[k]=i&j?1:0;
10 while (a[--k]==0);
11 for (;k >=0;k--)
12 printf("%d",a[k]);
13 return 0;
14 }

b) What does the following function do? describe, line by line, how it works.

1 int function(unsigned long i)
2 {
3 int k=1;
4 while (i>>=1){
5 k++;
6 }
7 return k;
8 }

problem4)a) How will you represent the following array as a sparse array using vector representation?

0 0 3 0 0 1 0
0 0 0 0 1 0 3
3 0 0 0 0 1 1
0 0 0 0 3 0 0
0 2 0 0 0 0 0
0 0 0 0 4 0 0
0 0 0 0 2 0 0

problem5) prepare a C program that creates a binary search tree and add the numbers 12, 3,0,7,8 and 9 to the tree. Your program should have a function to add nodes to a binary search tree.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M92606

Have any Question? 


Related Questions in C/C++

This program involves using stl listsfor this program you

This program involves using STL lists. For this program you will implement three functions whose prototypes are given below: list ::iterator mxIter(list ::iterator first, list ::iterator last); void selectSort(list & aLi ...

Problem 1 you are tasked to write a program that outputs

PROBLEM 1 You are tasked to write a program that outputs the following amplifier system specifications: Voltage amplification: 25 Input voltage: 50 mV Power output: 2.5 W Bandwidth: 15 kHz Type: Class A a. For this progr ...

Ipo chartinputprocessingoutputmarks for four

IPO Chart Input Processing Output Marks for four courses Processing Item: Grade Point and Grade for individual course Overall GPA Algoritham Initialize gp with zero Repeat  for (each course)                 Enter the mar ...

Cs492 programming assignment-the program must be written in

CS492 Programming Assignment- The program must be written in C or C++, and run on a linux machine. ALL source code you submit must be well documented (documentation is an indicator of understanding!) Programs that cannot ...

1 learner objectivesat the conclusion of this programming

1. Learner Objectives: At the conclusion of this programming assignment, participants should be able to: * Apply repetition structures within an algorithm * Construct while (), for (), or do-while () loops in C * Compose ...

1 write a program to find the sum amp average of the given

1) Write a program to find the sum & average of the given numbers using the while loop. 2) Write a program in C to find the sum and average of the given numbers stored in an array of n values.

Pa 1 word countertabulating basic document statistics is an

PA #1: Word Counter Tabulating basic document statistics is an interesting exercise that leverages your knowledge of strings, files, loops, and arrays. In this homework, you must write a C++ program that asks the user fo ...

C program assignmentaccording to C Program Assignment According to

C Program Assignment According to http://en.wikipedia.org/wiki/Great-circle_distance, the great circle distance based on two coordinates in nautical miles is given by: d = r * Δσ where r is the radius of the earth and Δσ ...

Fix a programthe program is already done and it runs welli

Fix a program The program is already done and it runs well.. I just need someone to fix it for me, the problem happens when you insert invalid day or invalid ticket type, I want you to end the program *at that point* as ...

Text exercise 413 gas mileagebulldrivers are concerned with

Text Exercise 4.13 (Gas Mileage) • Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several trips by recording miles driven and gallons used for each trip. Develop a C++ ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate