Home > Back-end >  C language problem
C language problem

Time:01-13

This is how to read characters, why I don't know how to calculate is 1 3
For bosses to solve

CodePudding user response:

Three expressions for statement is the first initialization the second is a judgment is the third cycle

CodePudding user response:

The first is' 1 ', assigned to c, judge another getchar (); So is the '2'! Output='#', '1', c=getchar (); Continue to be a '3', assigned to c; Judge '4'!
='#'
Output '3', '5' assigned to c, '#'!='#' is false, and, above all, the output should be '1', '3', namely, 13

CodePudding user response:

1, c=getchar ()//getchar () to get 1, after the assigned to c c='1'
2, getchar ()!//='#' getchar () to get 2, set up is not equal to the '#' conditions, into the loop body
3, putchar (c)//console print c: 1
4, to enter the second cycle, assignment statements is the third expression for
5, c=getchar ()//getchar () to get 3, assigned to the c=c after '3'
6, getchar ()!//='#' getchar () to get 4, set up is not equal to the '#' conditions, into the loop body
7, putchar (c)//console print c: 3
Eight, to enter the third cycle, assignment statements is the third expression for
9, c=getchar ()//getchar () to get 5, assigned to the c=c after '5'
10, getchar ()!//='#' getchar () to get #, is not equal to the '#' conditions are not set up, exit the loop body
11, exit the main, the console print results: 13

CodePudding user response:

reference 3 floor bow people water response:
1, c=getchar ()//getchar () to get 1, after the assigned to c c='1'
2, getchar ()!//='#' getchar () to get 2, set up is not equal to the '#' conditions, into the loop body
3, putchar (c)//console print c: 1
4, to enter the second cycle, assignment statements is the third expression for
5, c=getchar ()//getchar () to get 3, assigned to the c=c after '3'
6, getchar ()!//='#' getchar () to get 4, set up is not equal to the '#' conditions, into the loop body
7, putchar (c)//console print c: 3
Eight, to enter the third cycle, assignment statements is the third expression for
9, c=getchar ()//getchar () to get 5, assigned to the c=c after '5'
10, getchar ()!//='#' getchar () to get #, is not equal to the '#' conditions are not set up, exit the loop body
11, out of the main console print results: 13

Thank you thank you
  • Related