Program to print combination of 3 and 4

Question:
Write a program to print the combination of given two numbers ie, 3 and 4.
Logic:
- Get the number of combinations from the user.
- Find the length of the combination values.
- Then calculate the values using some formulas.
- And print the output values.
Algorithm:
- Get the number of combinations from the user.
- Find the length by using power function and gives the length of the array.
- Then the values are found by multiplying the previous number with 10.
- And add the numbers ie, 3 and 4 then store into the array.
- Then print the array values.
Program:
[code lang=”c”]
#include<stdio.h>
#include<math.h>
void main()
{
int n,k=1,i,d=0;
int a[100];
a[0]=3,a[1]=4;//assign values of 3 and 4 into array
clrscr();
printf("enter the number of combinations:");
scanf("%d",&n);
d=power(n);//function that returns sum of all 2 power 1…n and stores in d
for(i=0;i<d-2;i++)
{ k++;//increments the position in array
/* gives all combination of numbers by multiplying 10 and addition of 3&4*/
a[k]=(a[i]*10)+3;
k++;
a[k]=(a[i]*10)+4;
}
for(i=0;i<d;i++)//prints the combinatioinal values
{
printf("%d ",a[i]);
}
getch();
}
int power(int x)//function that defined for finding length
{
if(x!=0)
{
return pow(2,x)+power(x-1);
}
}
[/code]