Last active
May 21, 2025 14:20
-
-
Save saibhatia/72bcc8c4697390bccc955d5755380666 to your computer and use it in GitHub Desktop.
pattern rectangle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int rows; | |
scanf("%d",&rows); | |
int number=1; | |
for(int i=1;i<=rows;i++){ | |
for(int j=1;j<=i;j++){ | |
if(number%2==0) | |
printf("0 "); | |
else | |
printf("1 "); | |
number++; | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int n; | |
cin>>n; | |
char alp='A'; | |
int num=1; | |
int check=0; | |
for(int i=0;i<=n;i++){ | |
for(int j=0;j<=n-i;j++){ | |
cout<<" "; | |
} | |
for(int k=0;k<=i;k++){ | |
if(check==0){ | |
cout<<alp++<<""; | |
} | |
if(check==1){ | |
cout<<num++<<""; | |
} | |
} | |
cout<<"\n"; | |
if(check==0) check=1; | |
else check=0; | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int rows; | |
scanf("%d",&rows); | |
int number=1; | |
for(int i=1;i<=rows;i++){ | |
for(int j=1;j<=i;j++){ | |
printf("%d ",number); | |
number++; | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int rows; | |
scanf("%d",&rows); | |
for(int i=0;i<rows;i++){ | |
for(int j=0;j<=i;j++){ | |
printf("*"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int rows; | |
scanf("%d",&rows); | |
for(int i=1;i<=rows;i++){ | |
for(int j=rows;j>=1;j--){ | |
if(j>i) | |
printf(" "); | |
else | |
printf("*"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int rows,column; | |
scanf("%d%d",&rows,&column); | |
for(int i=0;i<rows;i++){ | |
for(int j=0;j<column;j++){ | |
if(i==0||i==(rows-1)||j==0||j==(column-1)) | |
printf("*"); | |
else | |
printf(" "); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int rows; | |
scanf("%d",&rows); | |
for(int i=0;i<rows;i++){ | |
for(int j=rows;j>i;j--){ | |
printf("*"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int rows; | |
scanf("%d",&rows); | |
for(int i=0;i<rows;i++){ | |
for(int j=1;j<=rows-i;j++){ | |
printf("%d",j); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int rows; | |
scanf("%d",&rows); | |
for(int i=1;i<=rows;i++){ | |
for(int j=1;j<=i;j++){ | |
printf("%d",j); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int rows; | |
scanf("%d",&rows); | |
for(int i=1;i<=rows;i++){ | |
for(int j=1;j<=rows;j++){ | |
if(j<=rows-i) | |
printf(" "); | |
else | |
printf("%d",rows-j+1); | |
} | |
for(int j=2;j<=i;j++){ | |
printf("%d",j); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int rows,column; | |
scanf("%d%d",&rows,&column); | |
for(int i=0;i<rows;i++){ | |
for(int j=0;j<column;j++){ | |
printf("*"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment