Question

In: Computer Science

Q1: The expression A = (E – F)/((P + (3*Q))*((2*R) – (5*S))) is not a valid...

Q1: The expression A = (E – F)/((P + (3*Q))*((2*R) – (5*S))) is not a valid SPLan assignment statement. Write a sequence of assignment statements that will perform the equivalent calculation.

Q2: Write a program which asks the user to input an integer. If the integer is less than zero, the program should output the message “Negative, the absolute value is ”, followed by the absolute value of the number. If the input is zero, the program should output the message “Zero.” If the input is greater than zero, the program should output the message “Positive.”

Solutions

Expert Solution

Q1.

#include <stdio.h>

int main()
{
// Variable Declaration   

int A,P,Q,R,E,F,S;

E=50;
F=10;
P=2;
Q=1;
R=2;
S=1;
//A=(E-F)/((P+(3*Q))*((2*R)-(5*S)));
Q=3*Q;
P=P+Q;
R=R*2;
S=S*5;
P=P*(R-S);
E=E-F;
E=E/P;
A=E;
printf("%d",A);
return 0;
}

Output Snapshots:

Q2

// C Code

#include <stdio.h>

int main()
{
int num;
printf("Enter an integer");
scanf("%d",&num);
if(num<0)
{
num=abs(num);
printf("Negative, the absolute value is %d",num);
}
else if(num==0)
printf("Zero");
else
printf("Positive");
return 0;
}
Output Snaphsot:


Related Solutions

Prove p → (q ∨ r), q → s, r → s ⊢ p → s
Prove p → (q ∨ r), q → s, r → s ⊢ p → s
Suppose S = {p, q, r, s, t, u} and A = {p, q, s, t}...
Suppose S = {p, q, r, s, t, u} and A = {p, q, s, t} and B = {r, s, t, u} are events. x p q r s t u p(x) 0.15 0.25 0.2 0.15 0.1 (a) Determine what must be p(s). (b) Find p(A), p(B) and p(A∩B). (c) Determine whether A and B are independent. Explain. (d) Arer A and B mutually exclusive? Explain. (e) Does this table represent a probability istribution of any random variable? Explain.
It is known that the sentence E: if (if P then not (Q or R) else...
It is known that the sentence E: if (if P then not (Q or R) else not P) then (not (Q and S) if and only if (not Q or not S)). Investigate whether I = {S ← false, R ← false, Q '← true, P ← false} interpretations are interpretations for sentence E.
FOR EAICH PAIR OF PROPOSITIONS P AND Q STATE WHETHER ON NOT p=q p=(s→(p ∧¬r)) ∧...
FOR EAICH PAIR OF PROPOSITIONS P AND Q STATE WHETHER ON NOT p=q p=(s→(p ∧¬r)) ∧ ((p→(r ∨ q)) ∧ s), Q=p ∨ t
1. Determine if the following deduction rule is valid: p∨q ¬p _______ ∴ q 2. Determine...
1. Determine if the following deduction rule is valid: p∨q ¬p _______ ∴ q 2. Determine if the following is a valid deduction rule: (p∧q)→r ¬ p ∨ ¬ q ________ ∴     ¬r 3. Suppose p and q are (possibly molecular) propositional statements. Prove that p and q are logically equivalent if any only if p↔q is a tautology.
Show that, for any events E and F, P(E ∪ F) = P(E) + P(F) −...
Show that, for any events E and F, P(E ∪ F) = P(E) + P(F) − P(E ∩ F). Only use the probability axioms and indicate which axiom you use where
Q1. a. Given a schema R (A, B, C, D, E, F) and a set F...
Q1. a. Given a schema R (A, B, C, D, E, F) and a set F of functional dependencies {A → B, A → D, CD → E, CD → F, C → F, C → E, BD → E}, find the closure of the set of functional dependencies ?+ b. Given a schema R = CSJDPQV and a set FDs of functional dependencies FDs = {C → CSJDPQV, SD → P, JP → C, J → S} 1. Find...
f: R[x] to R is the map defined as f(p(x))=p(2) for any polynomial p(x) in R[x]....
f: R[x] to R is the map defined as f(p(x))=p(2) for any polynomial p(x) in R[x]. show that f is 1) a homomorphism 2) Ker(f)=(x-2)R[x] 3) prove that R[x]/Ker(f) is an isomorphism with R. (R in this case is the Reals so R[x]=a0+a1x+a1x^2...anx^n)
Show that if P;Q are projections such that R(P) = R(Q) and N(P) = N(Q), then...
Show that if P;Q are projections such that R(P) = R(Q) and N(P) = N(Q), then P = Q.
Given the unordered array: [0] [1] [2] [3] [4] [5] [6] [7] [8] P E R...
Given the unordered array: [0] [1] [2] [3] [4] [5] [6] [7] [8] P E R Y I H J L S Suppose this array were being sorted using the quick sort algorithm from the course content, into ASCENDING order, with the left-most item as the pivot value. List the letters in the resulting array, in order AFTER the FIRST PARTITIONING. [0] [1] [2] [3] [4] [5] [6] [7] [8]
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT