Programming: Create the following three files: 1)main.c: main function that call
ID: 3756739 • Letter: P
Question
Programming: Create the following three files:
1)main.c: main function that calls printStrings(int length) in myfunctions.c
2)myfunctions.c: has two functions
• printStrings: initializes a string s and call printStringsRec
• printStringsRec: a recursive function that prints all possible binart strings of size ‘length’
such that printed strings have no consecutive 1’s.
• Example: if length=3 then output: 000, 001,010,100,101 but not 110 nor 011
3)myfunctions.h: a header file to hold the two functions prototypes.
//Main.c
int main() {
int length;
scanf(“Enter string length: %d”,&length);
printStrings(length) ;
return 0;
}
For submission please write the run command used and the printed output in
addition to the code.
(in c programming language)
Explanation / Answer
void rollover(int value,int countr) {
if(countr==0) {
return;
}
printf("%d ",value);
countr--;
rollover(value,countr);
}
int main() {
int arry[]={0,1};
for(int i=0;i<=1;i++) {
rollover(arry[i],4);
}
printf(" ");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.