Home Page > > Details

Q1

Write a C Program to read an integer from the screen and decide if it is odd or even.

[Hint: An expression: a % b produces the remainder when a is divided by b; and zero when there is no remainder]

Note: The programme should start:

#include

int main() {

int number;

printf("\nEnter an integer: ");

scanf("%d", &number);

The output should be like this (if 9 was the number input).

9 is an odd integer.

or for an even number

10 is an even integer.

Q2

The standard form of a quadratic equation is:

where a, b and c are real numbers, and a ≠ 0.

The term b^2-4ac is known as the discriminant of a quadratic equation. It tells the nature of the roots.

If the discriminant is greater than 0, the roots are real and different.

If the discriminant is equal to 0, the roots are real and equal.

If the discriminant is less than 0, the roots are complex and different.

Write a C program to find when the discriminant is greater than or equal to 0 and print the roots to 3 decimal places. Your program should output to the screen the largest root first if they are not equal. If the discriminant is less than zero print to screen “The roots are complex and different”.

Note: Start your code like this:

1. #include

2. #include

Q3

To do this problem, you should have the knowledge of the following C programming topics:

C switch Statement

C break and continue

Take an arithmetic operator +, -, *, / and two operands (integer numbers) from the user. Then, perform the calculation on the two operands depending upon the operator entered by the user. (For example the user chooses + and 2 and 3, so the output must be 5).

Please start the programme like this:

#include

int main() {

int operator;

float first, second;

printf("\nEnter an operator: \n 1 for+,\n 2 for -,\n 3 for *,\n 4 for /\n");

scanf("%i", &operator);

printf("\nEnter two operands:\n");

scanf("%f %f", &first, &second);

........

The output should be just the result of the arithmetic operation as a float with 4 decimal points. (i.e. if you add 2 and 3 the answer should be shown as : 5.0000).

Do not put any text before the answer. Just print the answer to the screen as a float to 4 decimal places !

Q4

Use the function below to calculate the power of a number (base).

int power(int base, int a) {

if (a != 0)

return (base * power(base, a - 1));

else

return 1;

}

The output should be formatted, for example for 2 raised to the power of 2, as shown here:

2^2=4

Contact Us(Ghostwriter Service)

- QQ：99515681
- WeChat：codinghelp
- Email：99515681@qq.com
- Work Time：8:00-23:00

- Programhelp With ,Help With C++ Course... 2022-05-10
- Help With Data Programming,Help With C... 2022-05-10
- 5Cce2sashelp With ,Python，Java Progra... 2022-05-10
- Help With Program Programming,Help Wit... 2022-05-09
- Help With Csci 3110,Help With Java，Py... 2022-05-09
- Mth2222help With ,Help With C/C++，Pyt... 2022-05-09
- Cse3bdchelp With ,Help With Sql Progra... 2022-05-08
- Help With Cis 468,Help With Java，Pyth... 2022-05-08
- Comp Sci 4094/4194/7094 Assignment 3 D... 2022-05-07
- Cs 178: Machine Learning & Data Mining... 2022-05-07
- Data7703 Assignment 4 2022-05-07
- Data Programminghelp With ,Help With S... 2022-04-25
- Help With Ait681 Course,Help With Pyth... 2022-04-25
- Cse121l Programminghelp With ,Help Wit... 2022-04-25
- Help With Iti1120,Help With Java，C/C+... 2022-04-25
- Cmt304help With ,Help With C++，Python... 2022-04-25
- Help With Engn4528,Matlab Programmingh... 2022-04-24
- Help With Fin 2200,Help With Java，Pyt... 2022-04-24
- Bism 7255Help With ,Help With Java，Py... 2022-04-23
- Comp202help With ,Help With Java Progr... 2022-04-23

Contact Us - Email：99515681@qq.com WeChat：codinghelp

© 2021 www.asgnhelp.com

Programming Assignment Help！