preview

Mat 540 Final Paper

Decent Essays

1. Why does the following program output -1? #include #include #include void main(){ system("cls"); long a = 2147483647; printf("%d", a); } 2. Write a program to calculate and display the y intercept of a point lying on a straight line using printf() (only one is allowed) and arithmetic operators where slope is 4, x coordinate is -1, and y coordinate in -6. a. Without using variables. b. With variables. 3. Write a program to calculate and display the slope of a straight line between two points i.e. (–2, 4) and (1, 2) respectively in a two-dimensional plane using the printf() (only one is allowed) and arithmetic operators. a. Without using variables. b. With variables. 4. Write a program to calculate and display the result of a second order equation where …show more content…

You can use the last two digits of your registration number as the value of x. a. Without using variables. b. With variables. 5. Write a program to determine discriminant (using appropriate arithmetic operators) of a second order equation where the values of constants a, b, and c are 1, 6, and 5 respectively. (Hint: use nested ternary operators). Display Message Condition There are two real roots. Where the value of discriminant > 0 There is one real root. Where the value of discriminant = 0 There are two complex roots. Where the value of discriminant < 0 a. Without using variables. b. With variables. 6. Generate the following truth table using logical operators: A B AND OR NAND NOR 0 0 0 0 1 1 0 1 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0

Get Access