W3 Questions
W3 Questions
(if - else)
Input: 8
Output: 8 is an even number.
Input:13
Output: 13 is an odd number.
Template.c
#include <stdio.h>
/* Include any headers here */
int main() {
int number;
Test Cases:
Input Output
32 32 is an even number.
223 223 is an odd number.
9999 9999 is an odd number.
25874 25874 is an even number.
500000001 500000001 is an odd number.
int main() {
int a,b,c;
Test Cases:
Input Output
56 The largest number is 97
97
36
223 The largest number is 458
458
369
9999 The largest number is 9999
-9999
999
25874 The largest number is 79656
79656
-99878
Template.c
#include <stdio.h>
/* Include any headers here */
int main() {
/* Put your declarations here */
int num;
Test Cases:
Input Output
32 The number 32 is not divisible by both 5 and 11.
55 The number 55 is divisible by both 5 and 11.
9999 The number 9999 is not divisible by both 5 and 11.
275 The number 275 is divisible by both 5 and 11.
33000 The number 33000 is divisible by both 5 and 11.
Template.c
#include <stdio.h>
/* Include any headers here */
int main() {
Test Cases:
Input Output
1 Roots are real and different.
-7 Root 1 = 4.00
12 Root 2 = 3.00
0 Invalid equation.
0
0
0 Invalid equation.
0
5
5. Write a C program that allows the user to choose from the following operations:
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exponentiation
6. Square Root
7. Natural Logarithm
The program should:
• Prompt the user for input based on the chosen operation.
• Handle errors such as division by zero, square root of a negative number, and
logarithm of non-positive numbers.
• Display appropriate results or error messages for invalid inputs.
Template.c
#include <stdio.h>
/* Include any headers here */
int main() {
Test Cases:
Input Output
Select an operation from the menu: 3.00
1. Addition (+)
2. Subtraction (-)
3. Multiplication (*)
4. Division (/)
5. Exponentiation (^)
6. Square Root (r)
7. Logarithm (l)
Enter your choice (1-7): 4
9
3