12344321
123**321
12****21
1******1
#include<stdio.h>
int main()
{
int i,j,k;
for(i=4;i>=1;i--)
{
for(j=1;j<=4;j++)
{
if(j<=i)
printf("%d",j);
else
printf(" ");
}
for(j=4;j>=1;j--)
{
if(j<=i)
printf("%d",j);
else
printf(" ");
}
printf("\n");
}
return 0;
}
Related Links:
- More Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
- Series Programs in C
sir this is completely wrong...
ReplyDeleteyes..this is not working..second loop will never run!!
ReplyDeletesorry for the above comment...the logic is absolutely correct...
ReplyDeletewrong!!!!!!!!!!!!!!!!!!!!!!!!!!
ReplyDeleteIt is perfect just in printf("*") instead of printf(" ") in both the cases
ReplyDeleteyes the code is crct only printf statmnt must be changed
ReplyDelete#include
ReplyDeleteint main()
{
int r,i,j,s,k;
printf("Enter the no. of rows : ");
scanf("%d",&r);
for(i=r;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
for(s=1;s<=2*(r-i);s++)
{
printf("*");
}
for(k=i;k>=1;k--)
{
printf("%d",k);
}
printf("\n");
}
}
This comment has been removed by the author.
ReplyDeletepublic class Patt10 {
ReplyDeletepublic static void main(String[] args) {
for(int i=4;i>=1;i--)
{
for(int j=1;j<=4;j++)
{
if(j>i) {
System.out.print("*");
}
else
{
System.out.print(j);
}
}
for(int k=4;k>=1;k--) {
if(k>i)
System.out.print("*");
else
System.out.print(k);
}
System.out.println();
}
}
I want to know code for
ReplyDelete12344321
123**321
12****21
1******1
12****21
123**321
12344321
543212345
ReplyDelete5432_2345
543___345
54_____45
5_______5
//C++ Code
ReplyDelete#include
using namespace std;
int main(){
int N,i,j;
int k;
cout<<"Enter number of rows:-"<>N;
for(i=1;i<=N;i++){
k=1;
int l=N-1;
for(j=1;j<=N;j++){
if(j<=N+1-i){
cout<=N+i){
cout<<k;
k--;
}
else
{
cout<<"*";
}
}
cout<<endl;
}
}
#include
ReplyDeleteusing namespace std;
int main(){
int n;
cin>>n;
int i=1;
while(i<=n){
int j=1;
while(j<=n-i+1){
cout<=1){
cout<<j;
j--;
}
cout<<endl;
i++;
}
}