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 is the basis for selection of arrays or pointers as data structure in a program

0 Answers   TCS,


i=10,j=20 j=i,j?(i,j)?i:j:j print i,j

1 Answers   CSC,


How can we open a file in Binary mode and Text mode?what is the difference?

1 Answers   PanTerra,


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

0 Answers  


main() { int x=10,y=15; x=x++; y=++y; printf("%d %d\n",x,y); } output??

19 Answers   EBS, Ramco, Sangwin, TCS,






What is the difference between Printf(..) and sprint(...) ?

0 Answers   InterGraph,


Why we use int main and void main?

0 Answers  


Calculate 1*2*3*____*n using recursive function??

0 Answers  


write a program for size of a data type without using sizeof() operator?

22 Answers   HCL, IBM,


There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.

0 Answers  


Write a program to swap two numbers without using third variable in c?

0 Answers  


wt is diference between int and int pointer as same as float and float pointer and char and char pointer

8 Answers   CTS, Infosys,


Categories