Saturday, October 26, 2013

Module VI

 Module VI
http://youtu.be/5qvt7oRMi80(Video Module VI)
In this code, it would like show you also use pointer with input data (scanf) by was defined by , array function, looping condition, and pointer function. For example in this code :
printf ("Type the siblings age you\n") ; for (k = 0; k<jml_sak; k++) { printf ("#%d ", k+1); // your looping condition depend of your inputting scanf ("%d", & age[k]); this code that expression that you input data with pointer function is:
printf ("Type the number of siblings you>"); scanf("%d",&jml_sak); // you can input your data use with pointer function.
The code show you about how show your sibling age by using array, looping condition, and pointer function.
Please look the flowchart of Module VI that consist with variable, operator, control flow, function, array, and pointer function.

Please look the code in below:
 #include <stdio.h>
 #include <stdlib.h>
#include <string.h>
 int main(void) {
int *age; // Declare array with pointers
 int jml_sak, k = 0;
printf ("Type the number of siblings you>");
 scanf("%d",&jml_sak);
age = (int*) malloc (sizeof (int) *jml_sak); //dynamic memory allocation
if (!age)
 {
printf ("Memory not available!\n");
system ("pause");
 return 0;
} /* input data is age */
 printf ("Type the siblings age you\n") ;
 for (k = 0; k<jml_sak; k++)
{
printf ("#%d ", k+1);
 scanf ("%d", & age[k]); } /* display the age data */
printf ("The data you input earlier age:\n");
for (k = 0; k<jml_sak; k++)
printf ("#%d %d\n", k+1,age[k]); /* download dealokasikan dynamic memory */
free (age);
 age = NULL;
 system ("pause");
return 0;
}


No comments:

Post a Comment