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

Answers were Sorted based on User's Feedback



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

Answer / ashim ghosh

#include<stdio.h>
#include<conio.h>
void main()
{
char arr[20]={"INDIA"};
int i,j;
for(i=0;i<=5-1;i++)
{
for(j=0;j<=i;j++)
{
printf("%c",arr[j]);
}
printf("\n")
}
getch();
}

Is This Answer Correct ?    18 Yes 11 No

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

Answer / 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

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

Answer / 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

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

Answer / ramesh k

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char name[20];
int a;

clrscr();
printf("enter the INDIA name");
scanf("%c",&name);
a=strlen(name);
for(int i=0;i<=a;i++)
{
for(int j=0;j<=i;j++)
{
printf("%c",name[i]);
}
printf("\n");
}
getch();
}

Is This Answer Correct ?    1 Yes 12 No

Post New Answer

More C Interview Questions

what would be the output of the following prog? Justify your answer? main() { unsigned char ch; unsigned char i; ch = -255; printf("%d",ch); i = -1; printf("%d",i); }

1 Answers  


1,4,8,13,21,30,36,45,54,63,73,?,?.

10 Answers   AMB, Franklin Templeton,


What is volatile c?

0 Answers  


what is the size of an integer variable?

4 Answers  


What is c language in simple words?

0 Answers  






Is c language still used?

0 Answers  


How can we allocate array or structure bigger than 64kb?

2 Answers   CSC,


write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

0 Answers   Lovely Professional University,


WRITE A PROGRAM TO PRINT THE FOLLOWING OUTPUTS USING FOR LOOPS. A) * B) ***** *** * * ***** * * *****

2 Answers  


How would you find a cycle in a linked list?

3 Answers   NSN,


the expression a=30*1000+2768; evalutes to a) 32768 b) -32768 c) 113040 d) 0

1 Answers  


A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none

0 Answers  


Categories