Not sure how to get rid of the spaces at the end. Thanks for any help
In first question
In the above code inner forloop placed after printing the digit so it makes i to print extra line
so modify to code following :
#include <stdio.h>
int main()
{
int userNum;
int i;
int j;
userNum=3;
for(i=0;i<=userNum;i++){
for(j=0;j<i;++j){ //prints the spaces before it prints
number
printf(" ");
}
printf("%d\n",i); //it prints number
}
return 0;
}
input of second program:
#include <stdio.h>
int main()
{
int numRows;
int numCols;
int i;
int j;
char c;
numRows=2;
numCols=3;
for(i=1;i<=numRows;i++){ //opens the loop for rows
c='A'; //initialized column value to A for every row
for(j=1;j<=numCols;j++){ //opens the loop for columns
printf("%d%c ",i,c++); //prints the row and columns seat
numbers
}
}
return 0;
}
Not sure how to get rid of the spaces at the end. Thanks for any help...
AT46.1: Nested loops: Indent text HALLENGE 461: Nested loops: Indent text Print numbers 0,1,2 userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces after the printed number. Ex userNum-3 prints 3 int noin(void){ 6 int 1- Your solution goes here 1e return...
For JAVA Please post code in bold. Thank you. Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces after the printed number. Ex: userNum = 3 prints: 0 1 2 3 Challenge 4.6.1: Nested loops ndent...
Computer Science I home> 4 8 Nested loops Feedback | 48.1 Nested loops Indent text Print numbers 0, 1,2userNum as shown, with each number indented by that number of spaces For each printed line, print the leading spaces, then the number, and then a newline Hint. Use i and j as loop variables (initialize i and j explicitly). Note. Avoid any other spaces like spaces after the printed number Ex userNum-3 prints