Skip to content

srinirad/IA2-Test1-Session2

Repository files navigation


1. Write a program to find the area of a triangle using following function signatures.
void input(float *base, float *height);
void find_area(float base , float height, float *area);
void output(float base, float height, float area);
input:
1
2
output:
the area of the traingle with base 1.000000 and height 2.000000 is 1.000000


2. Write a program to find if a triangle is scalene. A triangle is a scalene traingle if all the three sides of the triangle are not equal to each other.

<br> int input_side()
<br> int check_scalene(int a, int b, int c)
<br> void output(int a, int b, int c, int isscalene)


3. Write a program find whether a number is a composite number. A Composite number has a factor other than 1 and itself
int input_number();
int is_composite(int n);
void output(int n, int composite);
input:
8
output:
8 is a composite number.


4. Write a program to find Sum of composite number in an array of numbers different containing numbers entered by the user.
int input_array_size();
void input_array(int n, int a[n]);
int sum_composite_numbers(int n, int a[n]);
void out_put(int sum);
input:
1 2 7 8 12
output:
20
5. Write a program to find gcd (hcf) of two numbers.
int input();
int gcd(int a, int b);
void output(int a, int b, int gcd); input: 12 16 output 4


6. Write a program to reverse a string.
void input_string(char *a);
char *str_reverse(char *a);
void output(char *a,char *reversea);
input:
hello
output:
olleh


7. Write a program to find the area of a triangle
struct _triangle
{
float base,altitude,area;
}; <brtypedef _triangle Triangle
Triangle input_triangle();
void find_area(Traingle *t);
void output(Triangle t);
input:
2 3
output:
The area of triangle wwith base = 2.000000 and altitude = 3.000000 is 3.000000


8. Write a program to find the triangle with smallest area in n given triangles.
struct _triangle
{
float base,altitude,area;
};
typedef _triangle Triangle
int input_n();
Triangle input_triangle();
void input_n_triangles(int n, triangle t[n]);
void find_area(Triangle *t);
void find_areas_n(int n, Triangle t[n]);
Triangle find_smallest_triangle(int n, Triangle t[n]);

void output(int n, Triangle t[n], Triangle smallest);
void
input:
2 3
4 6
the smallest of triangles with base and height
2,3 and
4,6
is
triangle with base 2.000000, 3.000000 is 3.000000
The area of triangle wwith base = 2.000000 and altitude = 3.000000 is 3.000000

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages