-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pointers.c
42 lines (36 loc) · 957 Bytes
/
Pointers.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//WAP a program to add two numbers using pointers and functions.
// #include<stdio.h>
// void sum( int *a,int *b,int *t);
// int main()
// {
// int num1,num2,total;
// printf("Enter the 1st number: \n");
// scanf("%d",&num1);
// printf("Enter the 2nd number: \n");
// scanf("%d",&num2);
// sum( &num1, &num2, &total );
// printf("The sum is %d",total);
// return 0;
// }
// void sum( int *a,int *b,int *t)
// {
// *t=*a+*b;
// }
// WAP a program to find the area of a triangle using pointers and functions.
#include <stdio.h>
void area( int *b,int *h,float *ar);
int main()
{
int base,height;
float Area;
printf("Enter the base of the triangle : \n");
scanf("%d",&base);
printf("Enter the height of the triangle: \n");
scanf("%d",&height);
area(&base,&height,&Area);
printf("The area of the triangle is %f : ",Area);
}
void area( int *b,int *h,float *ar)
{
*ar=0.5*(*b)*(*h);
}