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

Transaction processing system tpsxyz electronics is one of

Transaction Processing System (TPS) XYZ Electronics is one of the most popular electronics companies In Sultanate of Oman the company offers affordable electronic gadgets such as mp3 players, portable movie players, mobi ...

Bankers algorithmimplement the bankers algorithm for

Banker's Algorithm Implement the Banker's algorithm for deadlock avoidance, that works on a given set of N processes and M resource types (N The input data and result is then displayed on the screen. You may use your pro ...

Programming assignmentwrite a c program that allows the

PROGRAMMING ASSIGNMENT Write a C program that allows the user to make some banking transactions. The program should first prompt the user to enter the current balance of his/her bank account (in dollars and cents). The p ...

A compiler that translates a high-level language into

A compiler that translates a high-level language into another high-level language is called a source-to-source translator. What advantages are there to using C as a target language for a compiler?

Programming in c assignmentwrite a c program that computes

Programming in C Assignment Write a C program that computes and outputs the current age of the United States in days (you can use 1776 as theUS founding year). You don't have to worry about fractional years or leap years ...

Intro to programming in c assignmentsince this is the last

Intro to Programming in C Assignment Since this is the last assignment, there will be no late submission. All programs must be electronically submitted by 5:00pm on Tuesday, December 2nd with NO EXCEPTIONS in order to re ...

Assignmentpart acomplete the following questionswrite c

Assignment Part A Complete the following questions: Write C++ code to open a document with the name Hello.txt, place the message "Hello, World!" in the document, and exit the document. Re open the file you closed, and re ...

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

Discussionwhile loops versus for loops please respond to

Discussion "While Loops versus For Loops" Please respond to the following: • Suppose you are writing a C++ program that plays a commercial video continuously within a kiosk at your favorite shopping mall within your home ...

1 we know that from ece 109 to calculate the

1. We know that from ECE 109, to calculate the equivalent resistance of a network of resistors in series in parallel are given by: Write a C++ program that asks the user to input values for resistors (as many as they wou ...

  • 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