8/8/2019 turbo c 2
1/12
Turbo CTurbo CPriscilla M. Sotelo
8/8/2019 turbo c 2
2/12
#include
void printarr(int a[]) {int i;for(i = 0;i
8/8/2019 turbo c 2
3/12
void foo(int array[10][10])
{
/* blabla*/
}
or
void foo(int array[10][])
{
/* blabla */
}
main(){
int array[10][10];
/* now pass the array to the function*/
foo( array );
}
8/8/2019 turbo c 2
4/12
getcharThis is a standard function that gets a character fromthe stdin.
getchThis is a nonstandard function that gets a characterfrom keyboard, does not echo to screen.
getcheThis is a nonstandard function that gets a characterfrom the keyboard, echoes to screen.
Use getchar if you want it to work on all compilers.
Use getch or getche on a system that supports it whenyou want keyboard input without pressing [Enter].
And note that the return value of all three is int!Youneed this to properly check for EOF.
8/8/2019 turbo c 2
5/12
gotoxy(x,y)
is an inbuilt function in C
this function is particularly useful indisplaying the output at a specificcoordinates on the screen, where x and y
are the parameters passed(they r the
coordinates).displayes your output on that portion of
the screen.
8/8/2019 turbo c 2
6/12
gotoxygotoxy ExampleExample
gotoxy(22,9);
printf("This machine does not allow
withdrawals less than P100.");
8/8/2019 turbo c 2
7/12
Switch statementSwitch statement
y A form of flow control, often used to
replace repetitive if-else blocks. It takes asingle integral value and performs a series
of comparisons against programmer-supplied values. As soon as one of the
values matches, execution of supplied
code begins.
8/8/2019 turbo c 2
8/12
Switch ExampleSwitch Exampleswitch(ch) {
/ *Note the syntax of the case lines - case value colon */
case '+':
case '-':
case '/':
case '*':
printf("operator\n");break ;
/* Also note the break statement. Without it, any operator matches
would "fall through" to the next printf statement. */
e 'a':case 'e':
case 'i':
case 'o':case 'u:
printf("vowel\n");break;
/* The default keyword specifies what action should be taken if no
matches have been made. */
default:
printf("consonant\n");}
8/8/2019 turbo c 2
9/12
Nested LoopNested Loop
y a loop within a loop, an inner loop withinthe body of an outer one.
y How this works is that the first pass of
the outer loop triggers the inner loop,which executes to completion. Then thesecond pass of the outer loop triggers theinner loop again. This repeats until the
outer loop finishes. Of course,a break within either the inner or outerloop would interrupt this process.
8/8/2019 turbo c 2
10/12
Multidimensional arraysMultidimensional arrays
C supports arrays of multiple dimensions,
which are stored in row-major order.Technically, C multidimensional arrays are
just one-dimensional arrays whoseelements are arrays. The syntax for
declaring multidimensional arrays is as
follows:y int array2d[ROWS][COLUMNS];
y array2d[4][3]
8/8/2019 turbo c 2
11/12
y http://knol.google.com/k/thiyagaraaj-m-
p/use-of-getch-getche-and-getchar-in-c/1lfp8o9xxpx13/101#
y http://www.java2s.com/Code/C/Function/
PassArrayintoafunction.htm
y http://ee.hawaii.edu/~tep/EE160/Book/cha
p7/section2.1.2.htmly http://tldp.org/LDP/abs/html/nestedloops.
html
8/8/2019 turbo c 2
12/12
y http://wiki.answers.com/Q/What_is_the_
switch_statement_in_C