Function Main
float var = 23.564327;
Declaring pointer variables upto level_4
Initializing pointer variables
ptr1 = &var;
ptr2 = &ptr1;
ptr3 = &ptr2;
ptr4 = &ptr3;
Output values
"Value of var = %f\n", var);
"Value of var using level-1"
" pointer = %f\n",
*ptr1);
"Value of var using level-2"
" pointer = %f\n",
**ptr2);
"Value of var using level-3"
" pointer = %f\n",
***ptr3);
"Value of var using level-4"
" pointer = %f\n",
****ptr4);
End
Value of var = 23.564327
Value of var using level-1 pointer = 23.564327
Value of var using level-2 pointer = 23.564327
Value of var using level-3 pointer = 23.564327
Value of var using level-4 pointer = 23.564327
Function Main
Declare Integer A
Declare Integer B
Declare Integer res
Output "Insert 2 numbers to calculate GCD"
Output "First number: "
Input A
Output "Second number"
Input B
Assign res = GCD(a,b)
Output res
End
Function GCD (Integer a, Integer b)
Declare Integer res
If a = 0
Assign res = b
Else
Assign res = GCD(b MOD a, a)
End
Return Integer res
#include <stdio.h>
int GCD(int a, int b);
int main() {
int a;
int b;
int res;
printf("Insert 2 numbers to calculate GCD:\n");
printf("First number: \n");
scanf("%d", &a);
printf("Second number:\n");
scanf("%d", &b);
res = GCD(a, b);
printf("%d\n", res);
return 0;
}
int GCD(int a, int b) {
int res;
if (a == 0) {
res = b;
} else {
res = GCD(b % a, a);
}
return res;
}
Function Main
Declare Integer fact1
Declare Integer fact2
Output " First factor"
Input fact1
Output "Second factor"
Input fact2
Output multiply(fact1, fact2)
End
Function multiply (Integer x, Integer y)
Declare Integer result
If y = 0
Assign result = 0
End
If y > 0
Assign result = x + multiply(x, y-1)
End
If y < 0
Assign result = -multiply(x, -y)
End
Return Integer result
#include <stdio.h>
int multiply(int x, int y);
int main() {
int fact1;
int fact2;
printf("First factor:\n");
scanf("%d", &fact1);
printf("Second factor:\n");
scanf("%d", &fact2);
printf("%d\n", multiply(fact1, fact2));
return 0;
}
int multiply(int x, int y) {
int result;
if (y == 0) {
result = 0;
}
if (y > 0) {
result = x + multiply(x, y - 1);
}
if (y < 0) {
result = (int) (-multiply(x, (int) (-y)));
}
return result;
}