arrey - # include <stdio.h> int main (void) cfw_ char...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
# include <stdio.h> int main (void) { char word[20]; word[0]='H'; word[1]='e'; word[2]='l'; word[3]='l'; word[4]='o'; word[5]=0; printf("the constents of word[] is -->%s\n",word); getchar(); getchar(); return(0); } output the constents of word[] is -->Hello # include <stdio.h> int main (void) { int numbers[100]; numbers[2]=10; --numbers[2]; printf("the 2nd (previous) element of arrey numbers is %d\n",numbers[2]); getchar(); getchar(); return(0); } output the 2nd (previous) element of arrey numbers is 9 Example: Display with For loop (print yourself) #include <stdio.h> int main(void) { int count; int values[100]; for( count = 0; count < 100; count++ ) values[count] = 10; getchar(); getchar(); return (0); } 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example: Display Values #include <stdio.h> int main(void) { int x; int values[] = { 1,2,3,4,5,6,7,8,9 }; for( x = 0; x < 9; ++x ) printf("Values [%d] is %d\n", x, values[x]); getchar(); getchar(); return (0); } Example: Copy a string #include <stdio.h> #include <string.h> int main(void) { char word[20]; strcpy( word, "hi there." ); printf("%s\n", word ); getchar(); getchar(); return (0); } . #include <stdio.h> int main(void) { int square[100]; int i; /* loop index */; int k; /* the integer */ /* Calculate the squares */ for (i = 0; i < 100; i++) { k = i + 1; /* i runs from 0 to 99 */
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

arrey - # include &lt;stdio.h&gt; int main (void) cfw_ char...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online