Lab2 Programming
Lab2 Programming
1. Write a program that reads two integers from the user then displays their sum, product,
difference, quotient and remainder
#include <stdio.h>
int main() {
scanf("%d", &num1);
scanf("%d", &num2);
return 0;
}
2. Write a program that reads two integers from the user then displays the larger number
followed by the words “is larger.” If the numbers are equal, display the message “These
numbers are equal.” Use only the single-selection form of the if statement.
#include <stdio.h>
int main() {
int num1, num2;
return 0;
}
3. Write a program that reads an integer and determines and displays whether it’s odd or even.
Use the remainder operator. An even number is a multiple of two. Any multiple of two leaves
a remainder of zero when divided by 2.
#include <stdio.h>
int main() {
int number;
if (number % 2 == 0) {
printf("%d is even.\n", number);
} else {
printf("%d is odd.\n", number);
}
return 0;
}
4. Write a program that reads two integers and determines and displays whether the first is a
multiple of the second. Use the remainder operator
#include <stdio.h>
int main() {
scanf("%d", &num1);
scanf("%d", &num2);
if (num1 % num2 == 0) {
} else {
return 0;
5.Using only the techniques you learned in Lecture ii, write a program that calculates the squares
and cubes of the numbers from 0 to 10 and uses tabs to display the following table of values:
#include <stdio.h>
int main() {
int number;
printf("Number\tSquare\tCube\n");
for (number = 0; number <= 10; number++) {
return 0;