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++

Cs 2410workshop make-up assignmentwrite a c program that

CS 2410 Workshop Make-Up Assignment Write a C++ program that will output to a file called output.txt EVERY 10 digit phone number from 713-000-0000 through 713-000-0998. These numbers MUST only contain an odd number of ev ...

Write a program that reads numbers from cin and then sums

Write a program that reads numbers from cin and then sums them, stopping when 0 has been entered. Construct three versions of this program, using the while, do - while , and for loops. Add the following to your program: ...

The second portion instruction shown below which is the

The second portion (instruction shown below) which is the actual C++ program is needed by this Saturday. Write a C++ program that is menu-driven that allows for the following menu choices:Load an exam: Loading an exam sh ...

Assessment taskthis coursework will allow you to

Assessment Task: This coursework will allow you to investigate some of the issues involved in writing threaded programs. You are to write a series of simple programs in C/C++ that will run under Linux, to illustrate how ...

Write a program to draw a symmetric shape of your own using

Write a program to draw a symmetric shape of your own using C++ user-defined functions and arrays. The program should draw a shape in its original and opposite forms (black and white and then white and black). Please con ...

Assignmentwhen writing c programs include comments in your

Assignment When writing C++ programs include comments in your code, make the program readable by indenting, use meaningful variable and function names, and produce meaningful output. This assignment will be to write a te ...

Writing a c code its a beginner level code design a class

Writing a C++ code, its a beginner level code. Design a class house that defines a house on a street. A house has a house number and an (x,y) location, where x and y are numbers between -10 and 10. the key member is plot ...

Object-oriented programming assignmentintroduction -nbspa

Object-Oriented Programming Assignment Introduction -  "A logical matrix or (0, 1) matrix is a matrix with entries from the Boolean domain B = {0, 1}. Such a matrix can be used to represent a binary relation between a pa ...

Write a c program that calculates and prints the average of

Write a C program that calculates and prints the average of two or more salaries entered by the user. The program should first prompt the user to enter the number of salaries to process (make sure: at least 2 salaries mu ...

Discussionkeyboard versus file input please respond to the

Discussion "Keyboard versus File Input" Please respond to the following: • Suppose you are designing a C++ application that needs to capture user input specifically via a keyboard or from a file. Determine the method tha ...

  • 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

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen