hi there, i specify other Looping codes but i am hardly to make an output like this.
Output should be like this (Ctrl+F9)
1
12
123
1234
12345
I'm not sure if i used \n for the new printf.
i need it on Wednesday but i guess i may fail to submit earlier, but if you can help me right away pls asap. thank you
Codes for While Loop:
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
clrscr();
while (i<=5;)
{
printf("%i\n" ,i);
i++;
}
getche();
return(0);
}
Codes for Nested Loop:
#include<stdio.h>
#include<conio.h>
int main()
{
int i, j;
clrscr();
for (i=1; i<=3; i++)
for (j=j; j<=5; j++)
printf("%i\t %i\n" , i,j);
getche();
return(0);
}
#include<stdio.h>
//#include<conio.h> // won't compile on cpp.sh, but ok with some compilers
int main()
{
int i; // seems to work ok. i would declare int i = 0; to make sure starts at 0
//clrscr(); // also won't compile on cpp.sh, part of conio.h
while (i<=5) // while (i<=5;), cannot have a semi-colon inside of while loop parentheses
{
printf("%i\n" ,i);
i++;
}
//getche(); // good function, won't compile on cpp.sh, okay with some compilers
// no need to use. not waiting for a menu. no screen to pause.
return(0);
}
#include<stdio.h>
//#include<conio.h> // won't compile on cpp.sh. good header
int main()
{
int i, j;
//clrscr(); // good function, won't compile, not supported on cpp.sh web site
for (i=1; i<=3; i++)
for (j=j; j<=5; j++) // j is starting at 0 when run on cpp.sh web.
printf("%i\t %i\n" , i,j);
//getche(); // won't compile on cpp.sh. doesn't have the header conio.h
return(0);
}
# include <stdio.h>
//# include <conio.h> // this won't run on cpp.sh web site.
int main()
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
printf("%d",j);
printf("\n");
}
return(0);
}