Computer Science, asked by ShanayaTrivedi, 1 year ago

Wrote a program to show the following pattern.
6
6 12
6 12 18
6 12 18 24
and also a program to show-
if n=3 then-
888
888
888
and if n=5 then-
55555
55555
55555
55555
55555
Please help me

Answers

Answered by VemugantiRahul
3
Hi there!
Here's the answer:

1. C program to show o/p as in (1):

#include<studio.h>
#include<conio.h>
int main() //Main function begins
{
//Declare variables
…int i,j;
// use for loop
// say rows as i and columns as j
/* in o/p, there are 4 rows & 4 columns so for loop of row (i) and column (j) has to repeat 4 /times */
…for(i=1 ; i<=4 ; i++)
……{
………for(j=1 ; j<=4 ; j++)
…………{
……………if(i>=j) printf("%d",6*j);
……………else printf("\n");
…………}
…return 0;
}

2. C program to show o/p as in (2) and(3):
#include<studio.h>
#include<conio.h>
int main() //Main function begins
{
//Declare variables
…int a,n,i,j;
/* Take n from the User. a is the Value of no. to be printers in o/p */
…printf("Enter values for n and a:\n");
…scanf("%d%d",&n,&d);
…for(i=1 ; i<=n ; i++)
……{
………for(j=1 ; j<=n ; j++)
…………{
……………printf("%d",a);
……………printf("\n");
…………}
……}
return 0;
}

Here
for showing o/p as in (2), just enter n and a value as 3 and 8 respectively

for showing o/p as in (3), just enter n and a value as 3 and 5 respectively

Note: Here just I used …… to follow indentation

;)
hope it helps
Comment if you need to know anything.

VemugantiRahul: ok?
VemugantiRahul: mark brainliest if it was helpful
ShanayaTrivedi: Thanks a lot!!
VemugantiRahul: my pleasure! anytime!
Similar questions