Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- /*write a program reading names and surnames of 15 student, storing them in an array and printing on the screen as follows;:
- name and surname or in a reserved order*/
- { // program shows writing ( reading) the data into (from) multidimensional array
- char c;
- char tab [15][2][20];
- int n, i ;
- do
- {
- printf("Enter students number(n<16):");
- i = scanf("%d", &n);
- fflush(stdin);//stdio.h -clearing the buffer
- }
- while (i ==0);
- system("cls");////stdio.h -clearing the screen
- for ( i = 0; i <n; i ++)
- {
- printf("Enter name of %d student: ", i+1);
- scanf("%19s", &tab[i][0]);
- fflush(stdin);
- printf("Enter surname of %d student: ", i+1);
- scanf("%19s", &tab[i][1]);
- fflush(stdin);
- printf("\n");
- }
- printf("Printing firstly name, than suname? t\n");
- fflush(stdin);
- c = getchar();
- printf("\n");
- if(c == 't' || c == 'T')
- for( i = 0; i <n; i ++)
- printf("%d %s %s\n", i+1, tab[i][0],tab[i][1]);
- else for (i = 0; i <n; i ++)
- printf("%d %s %s\n", i+1, tab[i][1],tab[i][0]);
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement