0% found this document useful (0 votes)
11 views

Pattern programing

The document contains multiple C programming code snippets, each implementing different patterns based on user input 'n'. The patterns include printing stars, numbers, and alternating binary digits in various arrangements. Each code snippet is structured with a main function that reads an integer and uses nested loops to generate the desired output.

Uploaded by

jainithish07
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Pattern programing

The document contains multiple C programming code snippets, each implementing different patterns based on user input 'n'. The patterns include printing stars, numbers, and alternating binary digits in various arrangements. Each code snippet is structured with a main function that reads an integer and uses nested loops to generate the desired output.

Uploaded by

jainithish07
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

A:

#include <stdio.h>

int main() {
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
printf("* ");
}

printf("\n");
}

return 0;
}

B:
#include <stdio.h>

int main() {
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
int l=1+i;
for(int j=0;j<n;j++){
if(l){
printf("%d",l);
}
}
printf("\n");
}

return 0;
}

C:
#include <stdio.h>

int main() {
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
for(int j=0;j<=i;j++){
printf("* ");
}
printf("\n");
}

return 0;
}

D:
#include <stdio.h>

int main() {
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
int l=1;
for(int j=0;j<=i;j++){
printf("%d",l);
l++;
}

printf("\n");
}

return 0;
}

E:
#include <stdio.h>

int main() {
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
for(int j=0;j<=i;j++){
if((i+j)%2==0){
printf("1");
}else{
printf("0");
}

}
printf("\n");

}
return 0;
}

F:
#include <stdio.h>

int main() {
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
for(int j=0;j<=i;j++){
int l;
l+=1;
printf("%d ",l);
}
printf("\n");

}
return 0;
}

G:
#include <stdio.h>

int main() {
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
printf("* ");
}
printf("\n");

}
return 0;
}

H:
#include <stdio.h>

int main() {
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
int l=n-i;
for(int j=i;j<n;j++){
printf("%d",l);
};
printf("\n");
}
return 0;
}

I:
#include <stdio.h>

int main() {
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
int l=1;
for(int j=i;j<n;j++){
printf("%d",l);
l++;
}

printf("\n");
}

return 0;
}

J:

You might also like