#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...
-
#include<stdio.h> #include<math.h> int main() { int dec=0,temp,i,inc=0,octal; printf("Enter octal numer to convert to deci...
-
#include<stdio.h> int main() { int dec,temp,i,j=1,octal=0; printf("Enter the decimal number : "); scanf("%d",...

No comments:
Post a Comment