pls give solution .... plssss...this 2 questions in C language 7. File f7.c Get
ID: 3749671 • Letter: P
Question
pls give solution .... plssss...this 2 questions in C language
7. File f7.c Get a positive integer, n, from the user. In one line your program will print n patterns. Each pattern is some A's folowed by some B's. The first pattern has 1 A and (n-1) B's. Each new pattern has one more A that the previous pattern and one fewer B. If n=4, the program will print: ABBBAABBA A ABA AAA 8. File f8.c Get a positive integer, n, from the user. Like the last problem but on one line make n copies of the result from the previous problem. If n-4 the program will print:Explanation / Answer
7. CODE:
#include <stdio.h>
int main(){
int n,i,j,k,l;
printf("Enter a number: ");
scanf("%d",&n);
int ca=0,cb=0;
k=1,l=3;
while(n!=0){
for(i=ca;i<k;i++){
printf("A");
}
for(j=cb;j<l;j++){
printf("B");
}
--n;
++k;
--l;
}
return 0;
}
8. CODE:
#include <stdio.h>
int main(){
int n,i,j,k,l,it;
printf("Enter a number: ");
scanf("%d",&n);
int ca=0,cb=0;
k=1,l=3;
int temp=n;
while(temp>0){
while(n!=0){
for(i=ca;i<k;i++){
printf("A");
}
for(j=cb;j<l;j++){
printf("B");
}
--n;
++k;
--l;
}
--temp;
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.