#include %26lt;stdio.h%26gt;
void main(void)
{
int a,i,j;
clrscr();
for(i=5; i%26gt;=1; i--)
{
for(j=1; j%26lt;=i; j++)
printf("%d",j);
printf("\n");
}
getche();
}
I need the Output as:
12345
2345
345
45
5
Thanks in advance...need it Urgently
Need help with a C Program?
ok here the code that i came up with also do you need that clrscr function if so sorry:
#include %26lt;stdio.h%26gt;
void main(void)
{
int a=1,i,j;
for(i=5; i%26gt;=1; i--)
{
for(j = a; j%26lt;=5; j++)
{
printf("%d",j);
}
printf("\n");
a++;
}
return;
}
the reason yours kept counting down is cause everytime you went back into the second for loop the was intialaited to one so i add a and had it counted up every time the second for loop was finished and just had the condition for the j loop be that it was less then or equal to five instead of i cause eveventally it would catch up at 3 so I hope this helps without the clrscr
EDIT: to albert this is C not C++ but that would work instead of using a you could just set it equal to i and it would do the same thing with less varibales and use less resources
Reply:#include %26lt;stdio.h%26gt;
void main(void)
{
clrscr();
int x=0, y=0;
for(x=1;x%26lt;=5;x++){
for(y=x;y%26lt;=5;y++){
printf("%d",y);
}
printf("\n");
}
getch();
}
Kindly try this.
Reply:Why do not you contact a freelancer from websites like http://getafreelnacer.com/ ?
Reply:#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
int a,i,j;
clrscr();
for(i=1; i%26lt;=5; i++)
{
for(j=i; j%26lt;=5; j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}
this program is a litlle altered but it will work.Wat this program does is that it will print the innner loop value and the condition is that is %26lt;=5 so first run of loop it will run from 1 to 5 then scond time 'j' will be initialised to 2 and not 1 as i have said j=i so therefore it will print from 2 to 5 and so on until last time it will print only 5 this program should work in case i am wrong plz forgive me.thank you
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment