How to print India by nested loop?
I
IN
IND
INDI
INDIA
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
#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 |
what is the basis for selection of arrays or pointers as data structure in a program
i=10,j=20 j=i,j?(i,j)?i:j:j print i,j
How can we open a file in Binary mode and Text mode?what is the difference?
What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
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(...) ?
Why we use int main and void main?
Calculate 1*2*3*____*n using recursive function??
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.
Write a program to swap two numbers without using third variable in c?
wt is diference between int and int pointer as same as float and float pointer and char and char pointer