Subjective Assignment 02 Basic Programs 02 Ans
Subjective Assignment 02 Basic Programs 02 Ans
1. Write a C program to input a number and find square root of the given number.
Example
Input
Enter any number: 9
Output
Square root of 9 = 3
Solution -
#include <stdio.h>
#include <math.h>
int main()
{
double num, root;
return 0;
}
2. Write a C Program to input two angles from user and find third angle of the
triangle.
Example
Input
Enter first angle: 60
Enter second angle: 80
Output
Third angle = 40
Solution -
#include <stdio.h>
int main()
{
int a, b, c;
return 0;
}
3. Write a C program to input base and height of a triangle and find area of the
given triangle.
Example
Input
Enter base of the triangle: 10
Enter height of the triangle: 15
Output
Solution -
#include <stdio.h>
int main()
{
float base, height, area;
return 0;
}
4. Write a C program to input side of an equilateral triangle from user and find
area of the given triangle.
Example
Input
Solution -
#include <stdio.h>
#include <math.h> // Used for sqrt() function
int main()
{
float side, area;
return 0;
}
5. Write a C program to input marks of five subjects of a student and calculate
total, average and percentage of all subjects.
Example
Input
Enter marks of five subjects: 95 76 85 90 89
Output
Total = 435
Average = 87
Percentage = 87.00
Solution -
#include <stdio.h>
int main()
{
float eng, phy, chem, math, comp;
float total, average, percentage;
return 0;
}
6. Write a C program to input principle, time and rate (P, T, R) from user and find
Simple Interest.
Example
Input
Enter principle: 1200
Enter time: 2
Enter rate: 5.4
Output
Solution -
#include <stdio.h>
int main()
{
float principle, time, rate, SI;
return 0;
}
7. Write a C program to input principle (amount), time and rate (P, T, R) and find
Compound Interest.
Example
Input
Enter principle (amount): 1200
Enter time: 2
Enter rate: 5.4
Output
Solution -
#include <stdio.h>
#include <math.h>
int main()
{
float principle, rate, time, CI;
return 0;
}