Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Explain different between data and information provide geographical examples for each


Simple Calculator - 2

Write a program to create a menu-driven calculator that performs basic arithmetic operations (+, -, *, /, and %).


Input


The input will be a single line containing two integers and operator(+, -, *, /, and %) similar to 3 + 5.



Output


If the given operator is "+", print the sum of two numbers.

If the given operator is "-", print the result of the subtraction of the two numbers.

If the given operator is "*", print the multiplication of the two numbers.

If the given operator is "/", print the result of the division of the two numbers.

If the given operator is "%", print the result of the modulus operation of the two numbers.


Favorite Stores Page

In this assignment, let's build a Favorite Stores Page by applying the concepts we learned till now. You can use the Bootstrap concepts as well.


Refer to the below image.



https://assets.ccbp.in/frontend/content/static-website/favourite-stores-output-img.png



Note

Try to achieve the design as close as possible.

Resources

Use the image URLs given below.


  • https://assets.ccbp.in/frontend/static-website/stores-img.png
  • https://assets.ccbp.in/frontend/static-website/amazon-logo-img.png
  • https://assets.ccbp.in/frontend/static-website/ikea-logo-img.png
  • https://assets.ccbp.in/frontend/static-website/bewakoof-logo-img.png
  • https://assets.ccbp.in/frontend/static-website/flipkart-logo-img.png


CSS Colors used:


Background color Hex Code values:

#894bca

#ffffff


Text color Hex Code values:


#f780c3

#ffffff

#323f4b

#7b8794


CSS Font families used:

  • Bree Serif

Write a program that will ask the user to enter a number less than 256 and print out the value of the

number expressed in binary.


Allison takes a trip to a “Cent Store” where all items cost less than one dollar and she purchases one

item. Ask for the cost of the item in cents. Remember that the cost will be less than one dollar.

Display the minimum number of coins needed to make change for Allison’s purchase from one dollar.

Also display the number of each type of coin. (Possible coins are pennies, nickels, dimes, and

quarters.)


State whether each of the following is true or false. Explain why.

  1. The default case is required in the switch selection statement.
  2. The break statement is required in the last case of a switch selection statement.
  3. The expression ( (x > y) && (a < b ) ) is true if either x > y is true or a < b is true.
  4. An expression containing the || operator is true if either or both of its operands are true.
  5. The comma (,) formatting flag in a format specifier (e.g., %,20.2f) indicates that a value should be output with a thousands separator.
  6. To test for a range of values in a switch statement, use a hyphen () between the start and end values of the range in a case label.
  7. Listing cases consecutively with no statements between them enables the cases to perform the same set of statements.

Exercise: FunctionsAndPrimeNumbers (25 Points)

The project name of this exercise is FunctionsAndPrimeNumbers.

The purpose of this assignment is to apply what you have learned about repetition structures and methods, as well as continue to use the concepts you have already learned. Additionally, you learn about how to create your own header files and implementation files.

Problem Description

Introduction A function is a named sequence of instructions that performs a specific task and returns the result of its computation. Once defined, it can be then called in your program wherever that particular task should be performed.

A function can receive zero or more arguments. For example, consider a function sum, which receives three arguments, here named a, b, and c, and returns their sum: 


Task A int sum(int a, int b, int c) { // your code is here;

} To execute (or call) a function, you must supply its arguments. For example, if you want to compute the sum of 500, 600, and 700, you can write: sum(500, 600, 700).

A complete program example:

include

using namespace std;

/* Defining a function that computes the sum of three integers */ int sum(int a, int b, int c) { // your code is here;

}

int main() { // We call it with the actual arguments 1, 20, 300, // and save the result in a variable x int x = sum(1, 20, 300);

cout << x << endl; // Prints 321 }


Task B Let’s define a function that computes the maximum of two integers: /* Returns the maximum of two arguments */ int max2(int a, int b) { // your code is here } Then one can find the maximum of thee integers, for example, like this:

max2(max2(135, 8763), 500 ) // would return 8763 Execution of a function call


Task C. Is divisible? Write a program numbers.cpp that defines a function

bool isDivisibleBy(int n, int d); If n is divisible by d, the function should return true, otherwise return false.

For example: isDivisibleBy(100, 25) == true isDivisibleBy(35, 17) == false The program should also have a main function that tests your code. For example, it can ask the user to input two integer numbers and print Yes if the first number is divisible by the second, otherwise print No.


Task D. Is a prime? A prime number is an integer greater or equal to 2 that is only divisible by 1 and by itself. The first few primes are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47 …

N is a prime if and only if it is not divisible evenly by any of the numbers from 2 to N−1. Let’s implement this decision as a function.

In the same program numbers.cpp, add a function

bool isPrime(int n); The function should return true if n is a prime, otherwise return false. Change the

main function to test your new code.


Task F. Next prime Add a function

int nextPrime(int n); that returns the smallest prime greater than n.

For example: nextPrime(14) == 17 nextPrime(17) == 19 Change the main function to test the new code.


Task G. Count primes in range Add a function

int countPrimes(int a, int b); that returns the number of prime numbers in the interval a ≤ x ≤ b. Change the main function to test the new code.


Task H. Is a twin prime? A prime number N is called a twin prime if either N-2 or N+2 (or both of them) is also a prime. For example, a prime 17 is a twin prime, because 17+2 = 19 is a prime as well. The first few twin primes are: 3, 5, 7, 11, 13, 17, 19, 29, 31 …

Add a function

bool isTwinPrime(int n); that determines whether or not its argument is a twin prime. Change the main function to test the new code.


Task I. Next twin prime Add a function

int nextTwinPrime(int n); that returns the smallest twin prime greater than n. Change the main function to test the new code.


Task J. Largest twin prime in range Add a function

int largestTwinPrime(int a, int b); that returns the largest twin prime in the range a ≤ N ≤ b. If there is no twin primes in range, then return -1.

For example: largestTwinPrime(5, 18) == 17 largestTwinPrime(1, 31) == 31 largestTwinPrime(14, 16) == -1 Change the main function to test the new code.

_Hint: Try to reuse your functions you just have created in the next onces. _Warning: Do not use really big hmbers upon testing your code, remember "Prime number search is a source extencive operation."


a)     Write a C/C++ windows system program to move a file to a new location using the MoveFile function.

 

b)     Write a C/C++ windows system program to delete a file using the DeleteFile function. 


  1. a) Compare and contrast systems programming in Windows as against systems programming in
  2. Unix/Linux.    


b) Identify the features of each of these OS platforms that makes it suitable for system

programming.

 

2.     Using the Windows API, Write a C/C++ program to create a file in Windows and write some

text to the file.

 


Write a program to triple the salary of workers


LATEST TUTORIALS
APPROVED BY CLIENTS