How to print India by nested loop?
I
IN
IND
INDI
INDIA
Answer Posted / chavidi
void main()
{
char a[20];
int i,j,k;
clrscr();
gets(a);
j=strlen(a);
i=0;
while(i<j)
{
for(k=0;k<=i;k++)
{
printf("%c",a[k]);
}
printf("\n");
i++;
}
}
//APPLICABLE FOR ANY STRING
| Is This Answer Correct ? | 19 Yes | 12 No |
Post New Answer View All Answers
What does typedef struct mean?
What are the rules for the identifier?
What is difference between structure and union?
Do you know the difference between exit() and _exit() function in c?
What is calloc()?
Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.
What is class and object in c?
What is the hardest programming language?
What are loops c?
What are global variables and explain how do you declare them?
What are the properties of union in c?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
What is the benefit of using an enum rather than a #define constant?
What is pivot in c?
what is reason of your company position's in india no. 1.