#include<stdio.h>
#include<string.h>
int main()
{
int i,j;
char a[50];
scanf("%s",a);
int t=strlen(a)-1; //set right side diagonal start value
for(i=0;i<strlen(a);i++)
{
for(j=0;j<strlen(a);j++)
{
if(i==j&&j==t){
printf("%c",a[i]);--t; // to print mid value
}
else if (i==j){
printf("%c",a[i]); // to print left to right diagonal
}
else if(j==t&&j!=i){
printf("%c",a[t]);--t;} // to print right to left diagonal
else
printf(" "); // to print spaces between spaces
}
printf("\n"); // to print on new line
}
return 0;
}OUTPUT :
Monday, 5 June 2017
C program to print X pattern
Subscribe to:
Post Comments (Atom)
Home Page
Zoho Interview Questions Alternate Sorting C program for Circular Pattern C program for Spiral Matrix C program to print ...
-
Eg 1: Input: a1b10 Output: abbbbbbbbbb Eg: 2: Input: b3c6d15 Output: bbbccccccddddddddddddddd The number varies from 1 to 9...
-
Zoho Interview Questions Alternate Sorting C program for Circular Pattern C program for Spiral Matrix C program to print ...
-
#include<stdio.h> #include<string.h> int main() { int i,j; char a[50]; scanf("%s",a); int t=strlen(a)-1; /...
No comments:
Post a Comment