Write a program to find cube of a number.
Used Function
Used Recursion
#include<stdio.h>
int iterator = 2;
int givenValue=0;
int cube(int num)
{
if(!iterator)
{
printf("Cube of %d is : %d ", givenValue, num/givenValue);
return;
}
else
{
iterator--;
cube(num*num);
}
}
int main()
{
int n=0;
printf("Enter the number to find the cube\n");
scanf("%d",&givenValue);
cube(givenValue);
}
//maybe the below program is incorrect
Used Function
- #include <stdio.h>
- int cube(int num);
- int main()
- {
- int num;
- int c;
- printf("Please enter a number: ");
- scanf("%d", &num);
- c = cube(num);
- printf("Cube of %d is : %d", num, c);
- return 0;
- }
- int cube(int num) {
- return (num*num*num);
- }
Used Recursion
#include<stdio.h>
int iterator = 2;
int givenValue=0;
int cube(int num)
{
if(!iterator)
{
printf("Cube of %d is : %d ", givenValue, num/givenValue);
return;
}
else
{
iterator--;
cube(num*num);
}
}
int main()
{
int n=0;
printf("Enter the number to find the cube\n");
scanf("%d",&givenValue);
cube(givenValue);
}
//maybe the below program is incorrect
- #include <stdio.h>
- int cube(int);
- int main()
- {
- int n;
- int c;
- printf("Please enter a number: ");
- scanf("%d", &n);
- c = cube(n);
- printf("Cube of %d is : %d", n, c);
- return 0;
- }
- int cube(int num) {
- return (num*num*num);
- }
একটি মন্তব্য পোস্ট করুন