For 1 through 11, create an expression using the relational operators, the logical operators, and variable names of your own choosing, no if or variable declaration is necessary.
(x < 1) && (x > 10)
(y >= 1) && (y <= 10)
Write appropriate if statements for each of the following conditions:
Write the code and trace for the following:
1. Design an algorithm that will receive two integers items and display to the screen their sum, difference, product, and quotient. Do not allow divide by zero to occur.
2. Design an algorithm that will read two numbers and an integer code from the screen (print a menu of the choices first). If the code is 1, compute the sum of the two numbers. If the code is 2, compute the difference of the first number minus the second. If the code is 3, compute the product. If the code is 4 and the second number is not 0, compute the quotient (divide the first number by the second). If the code is not 1,2,3, or 4, display an error message. Finally, display the two numbers, the code, and the result (echo the input).
1. (age==30)
2. (temperature>98.6)
3. (height<6)
4. (month==12)
5. (input==m)
6. (age==30 && height>6)
7. (lenght>2 && lenght<3)
8. (taxRate>25 && income<20000)
9.(temperature<=75 || humidity<70)
10.(age>21 && age<60)
11.(age==21 || age==22)
12. condition never be true
13. 1,2,3,4,5,6,7,8,9,10
14. if(angle==90)
printf("The angle is a right angle");
else
printf("The angle is not a right angle");
15. if(temperature>100)
printf("above the boiling point of water");
else
printf("below boiling point");
16.if(number>0)
posSum=posSum+number;
else
negSum=negSum+number;
17. if(slope<5)
flag=0;
else
flag=1;
18. //Program is in C
#include<stdio.h>
int main()
{
int number;
printf("Enter a number");
scanf("%d",&number);
if(number>0)
printf("positive");
else if(number<0)
printf("negative");
else if(number==0)
printf("zero");
else
printf("Enter a
valid number");
}
19. //Program is in C
#include<stdio.h>
int main()
{
int a,b,c;
printf("Enter a number 1 :");
scanf("%d",&a);
printf("Enter a number 2 :");
scanf("%d",&b);
printf("Enter a number 3 :");
scanf("%d",&c);
if(a>b && a>c)
printf("%d is
max",a);
else if(b>a &&
b>c)
printf("%d is
max",b);
else if(c>a &&
c>b)
printf("%d is
max",c);
else
printf("all are
equal");
}
20. //Program is in C
#include<stdio.h>
int main()
{
float temperature;
printf("Enter temperature");
scanf("%f",&temperature);
if(temperature==0)
printf("freezing
point");
else if(temperature==100)
printf("boiling
point");
else if(temperature>=0
&& temperature<100)
printf("liquid");
else
printf("enter
valid");
}
Algorithms and Codes;
1)
1. Start
2. Enter value of the variable a
3. Enter value of the variable b
4. Calculate p (p = a + b)
5. Display result of addition, value of p on the
monitor with the message "The sum of a and b is:"
6. Calculate q (q = a - b)
7.Display result of subtraction, value of q on the
monitor with the message "The difference of a and b is:"
8.Calculate r (r = a*b)
9.Display result of multiplication, value of r on the
monitor with the message "The multiplication of a and b is:"
10.if b not equal to zero,go to step 11,otherwise go
to step 13.
11.Calculate s (s = a/b)
12.Display result of division, value of s on the
monitor with the message "The multiplication of a and b is:"
13. tell the user division not possible with zero
.
14.End
//C code
#include<stdio.h>
int main()
{
int a,b,p,q,r;
int s;
printf("Enter number 1:");
scanf("%d",&a);
printf("Enter number 2:");
scanf("%d",&b);
p=a+b;
printf("\nAddition is %d",p);
q=a-b;
printf("\nsubtraction is %d",p);
r=a*b;
printf("\nmultiplication is %d",p);
if(b!=0){
s=a/b;
printf("\ndivision is %d",s);
}
else
printf("\ndivision not possible with zero");
}
2)
1. Start
2. Enter value of the variable a
3. Enter value of the variable b
4.Display operations
1.addition
2.difference
3.Multiplication
4.Division
5.Enter operation number
6.if operation number is 1,goto 7
7. Calculate result (result = a + b)
8.if operation number is 2,goto 9
9. Calculate result (result = a - b)
10.if operation number is 3,goto 11
11.Calculate result (result = a*b)
12.if operation number is 4,goto 13
13.if b not equal to zero,go to step 14,otherwise go
to step 15.
14.Calculate result (result = a/b)
15. tell the user division not possible with
zero
16.Display a,b,result.
17.End
c code :
#include<stdio.h>
int main()
{
int a,b,result,op;
printf("Enter number 1:");
scanf("%d",&a);
printf("Enter number 2:");
scanf("%d",&b);
printf("\nChoose operation :");
printf("\n\t1.Addition");
printf("\n\t2.difference");
printf("\n\t3.multiply");
printf("\n\t4.division");
printf("\n\tenter operation");
scanf("%d",&op);
switch(op)
{
case 1:
result=a+b;
break;
case 2:
result=a-b;
break;
case 3:
result=a*b;
break;
case 4:
{
if(b!=0)
result=a/b;
else
printf("\ndivison not possible with zero");
}
break;
}
printf("\nNumber1 is %d",a);
printf("\nNumber2 is %d",b);
printf("\noperation is %d",op);
printf("\nresult is %d",result);
}
For 1 through 11, create an expression using the relational operators, the logical operators, and variable...
1. Using logical operators modify the following Python "if" statement to print ("AND operator condition worked")? x=2 y=3 if (x<=2 or y>=3) and (x>2 or y<2): print("AND operator condition worked") else: print("it doesn't work") 2. Write a program that asks user for five numbers and returns the largest of them. Do not use max function built in python.
Write an ARM program that implements a simple four-function calculator and prompts the user to enter a pair of decimal integers (A and B) followed by a character that specifies one of the operators: ‘+’ for addition to compute A+B ‘-‘ for subtraction to compute A-B ‘*’ for multiplication to produce the product A*B ‘/’ for division to produce the quotient A/B. Input should be the pair of numbers followed by the operand followed by a return. For example...
1. Prompt the user for one of the arithmetic operators ('op'): +, -, *,/, or ** 2. Prompt the user for two input integers ('a' and'b') 3. The input numbers can be positive or negative 4. Perform the arithmetic operation using the two input numbers 5. The first entered number ('a') is the left side, the second ('b') the right side of the operation For exponentiation, the first number is the base, the second the exponent Print (display) the following...
Create a method based program to find if a number is prime and then print all the prime numbers from 1 through 500 Method Name: isPrime(int num) and returns a boolean Use for loop to capture all the prime numbers (1 through 500) Create a file to add the list of prime numbers Working Files: public class IsPrimeMethod { public static void main(String[] args) { String input; // To hold keyboard input String message; // Message...
this is written in c++
This code needs to work with any input to have the output with
different numbers that are entered in.
Please help me I need help with this problem.
Thanks
$ Section 4.4 is a part of assignment Lab21: Number Divisible by 4 and/or 5 Requirements: zylab Entire class due: 03/01/2020, 11:59 PM 4.4 Lab 21: Number Divisible by 4 and/or 5 Write a program that reads in an integer number. It should then determine if...
Division by Zero Problem: Create a program titled Division. Have the program prompt the user "Enter numerator and denominator" and store the two values entered. (If you wish the user to "Enter numerator/denominator" be sure to adjust your data gathering variables to include a holder variable for the slash character.) Include a function titled Quotient that takes 2 integers as input and provides the quotient of the 2 integers as integer output. (The remainder is truncated. Thus, 5/3 will be...
Write a C program that reads a sequence of numbers and display a message 1. The numbers a re red from the standard input. 2. The first number is the length of the sequence (n) followed by n numbers. 3. If n is 0 or negative, the program displays the message "Error_1" followed 4. If the length is shorter than n, it displays "Error_2" followed by a new line 5. The program inspects the list and display one of the...
Give the solution using Python programming for following with explanations: a. Take two numbers and display which number is positive and which number is negative. b. Take two numbers divide and display quotient and reminder. c. Take two numbers and check if they are same or not same. a. Write four differences between high level language and low level language? b. Write all the rules of naming any variables in python and provide at least one example for each rule?...
Write in python code
Project 11-1: Birthday Calculator Create a program that accepts a name and a birth date and displays the person's birthday the current day, the person's age, and the number of days until the person's next birthday Console Birthday Calculator Enter name: Joel Enter birthday (MM/DD/YY): 2/4/68 Birthday: Sunday, February 04, 1968 Today: Joel is 48 years old. Joel's birthday is in 73 days Tuesday, November 22, 2016 Continue? (y/n): y Enter name: Django Enter birthday (MM/DD/YY):...
using C geany. Please Dr. exercise # 1 and 2
During the lab: PART I: PROGRAMMING EXERCISES a. Using Geany, write a C program that prompts and asks the user for two assignment marks (al and a2) and two test marks (ti and t2). All four variables are integer variables and are in % (out of 100). You program should display the four marks properly lalebed to check if the input has been successful. b. Next, calculate and display the...