Computer Science Practical Solution
Computer Science Practical Solution
#include <stdio.h>
int main() {
float length, width, area, perimeter;
// Calculations
area = length * width;
perimeter = 2 * (length + width);
// Output results
printf("Area of Rectangle: %.2f\n", area);
printf("Perimeter of Rectangle: %.2f\n", perimeter);
return 0;
}
Algorithm:
1. Start
2. Input length and width of the rectangle
3. Calculate area (area = length * width)
4. Calculate perimeter (perimeter = 2 * (length + width))
5. Display area and perimeter
6. Stop
#include <stdio.h>
int main() {
int num;
// Input from user
printf("Enter a number: ");
scanf("%d", &num);
return 0;
}
Algorithm:
1. Start
2. Input a number
3. Check if number is divisible by 2
- If true, print 'Even'
- Else, print 'Odd'
4. Stop
Viva-Voce Questions
1. What is an algorithm? - An algorithm is a step-by-step procedure to solve a problem.
3. What is the difference between scanf and printf in C? - scanf is used for input, and printf is
used for output.
4. What is the difference between an even and an odd number? - An even number is
divisible by 2, while an odd number is not.