How to print India by nested loop?
I
IN
IND
INDI
INDIA

Answer Posted / rashi

class Find{
public static void main (String args[])
{
String s="India";
int i,j;
l=s.length();
for(i=0;i<l;i++)
{
for (j=0;j<=i;j++)
{
char ch=S.charAt(i);
System.out.print(ch);
}
System.out.println(" ");
}
}
}

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of in c?

566


Why shouldn’t I start variable names with underscores?

618


Explain what is the general form of a c program?

616


Why flag is used in c?

645


1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321

3132






Explain what happens if you free a pointer twice?

602


What is difference between constant pointer and constant variable?

614


What are the advantages of using macro in c language?

581


Explain how can you restore a redirected standard stream?

583


Is c easier than java?

560


How reliable are floating-point comparisons?

621


Write a program to print fibonacci series using recursion?

577


What's a good way to check for "close enough" floating-point equality?

617


What happens if a header file is included twice?

580


Explain how do you generate random numbers in c?

612