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


Please Help Members By Posting Answers For Below Questions

What is the best way to store flag values in a program?

574


What does int main () mean?

539


What is pointers in c?

640


Write a C program in Fibonacci series.

622


What is use of integral promotions in c?

658






You have given 2 array. You need to find whether they will create the same BST or not. For example: Array1:10 5 20 15 30 Array2:10 20 15 30 5 Result: True Array1:10 5 20 15 30 Array2:10 15 20 30 5 Result: False One Approach is Pretty Clear by creating BST O(nlogn) then checking two tree for identical O(N) overall O(nlogn) ..we need there exist O(N) Time & O(1) Space also without extra space .Algorithm ?? DevoCoder guest Posted 3 months ago # #define true 1 #define false 0 int check(int a1[],int a2[],int n1,int n2) { int i; //n1 size of array a1[] and n2 size of a2[] if(n1!=n2) return false; //n1 and n2 must be same for(i=0;ia1[i+1]) && (a2[i]>a2[i+1]) ) ) return false; } return true;//assumed that each array doesn't contain duplicate elements in themshelves }

2704


the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters

1793


What is header file in c?

597


an expression contains relational operators, assignment operators, and arithmatic operstors. In the absence of parentheses, they will be evaluated in which of the following order a) assignment, relational, arithematic b) arithematic, relational, assignment c) relational, arithematic, assignment d) assignment, arithematic, relational

800


What is the use of typedef in structure in c?

536


struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer

755


Is array name a pointer?

597


What is the function of multilevel pointer in c?

665


a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above

645


Explain how can I pad a string to a known length?

639