#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)
C-Program to know whether the character is vowel or not
#include<stdio.h> int main() { char c; printf("Enter a character to know whether it is vowel or not\n"); scanf("...
-
Various Operations On An Array: Insert an element to an array Delete an element from an array Traverse the given array Search an element in...
-
Call Taxi Booking import java.util.Scanner; public class Main { public static v...
-
Spiral Matrix Assume the size of the matrix is odd. Sample Input: 3 1 2 3 4 5 6 7 8 9 S...

No comments:
Post a Comment