Write a c program using for loop to print typical pattern if
number of rows is entered by keyboard.
ABCBA
AB BA
A A



Write a c program using for loop to print typical pattern if number of rows is entered by keyboard...

Answer / a.jayashree

#include<stdio.h>
#include<string.h>
main()
{
char a[5];
int i=0,j=0;
printf("enter the string");
scanf("%s",a);
printf("\n%s",a);
for(i=0;i<a[5];i++)
{
if(a[i]==a[2])
{
printf("\n\t");
}
else
{
printf("%s",a);
}
}
for(j=0;j<a[5];j++)
{
if(a[j]==a[1])
{
if(a[j]==a[2])
{
if(a[j]==a[3])
{
printf("\n\t\t\t");
}
else
{
printf("%s",a);
}
}
}
}
}

Is This Answer Correct ?    2 Yes 6 No

Post New Answer

More C Interview Questions

#include<stdio.h> void main() { char *str; long unsigned int add; str="Hello C"; add=&str[0]; printf("%c",add); } What is the output?

4 Answers   Infosys,


Look at the Code: main() { int a[]={1,2,3},i; for(i=0;i<3;i++) { printf("%d",*a); a++; } } Which Statement is/are True w.r.t the above code? I.Executes Successfully & Prints the contents of the array II.Gives the Error:Lvalue Required III.The address of the array should not be changed IV.None of the Above. A)Only I B)Only II C)II & III D)IV

5 Answers   Accenture,


main() { char *p; p="Hello"; printf("%c\n",*&*p); }

2 Answers   ME,


write an algorithm to display a square matrix.

0 Answers  


what is real time system?what is the differance between hard and soft real time systems

2 Answers  






WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER

0 Answers  


Explain how do you print an address?

0 Answers  


write a programming in c to find the sum of all elements in an array through function.

0 Answers  


What are nested functions in c?

0 Answers  


How to swap two values using a single variable ? condition: Not to use Array and Pointer ?

6 Answers  


a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if

0 Answers  


Why we use conio h in c?

0 Answers  


Categories