rehearsal - :( structure) struct _Student cfw_ char *name;...

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

View Full Document Right Arrow Icon
הנבמל םיסחייתמ ונא הלאשה לש הז ףיעסב ) structure ( אבה ןפואב רדגוהש : struct _Student { char *name; /* The student s name. */ float average; /* The student s average */ }; typedef struct _Student Student; ומכ - היצקנופה ונל הנותנ ןכ : void init_student (Student *p_student, char *name, float average) { p_student->name = name; p_student->average = average; return; }
Background image of page 1

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

View Full DocumentRight Arrow Icon
םיטנדוטס לש םיעצוממו תומש טולקל הרומא האבה תינכתה , סיפדהל ןכמ רחאלו טנדוטס לכ לש עצוממהו םשה תא : #include<stdio.h> #define N_STUDENTS 30 #define MAX_LEN 40 int main () { Student class[N_STUDENTS]; char name[MAX_LEN + 1]; float average; int i; printf("Enter the names and averages\n"); for(i = 0; i < N_STUDENTS; i++) { scanf ("%s %f", name, &average); init_student (&(class[i]), name, average); } for (i = 0; i < N_STUDENTS; i++) printf("%s: %f", class[i].name, class[i].average); return 0; } תינכתב היעבה המ ? התוא ןקתנ דציכ ?
Background image of page 2
האבה היצקנופה השוע המ ? ומכ - ןכ , רבעומש ךרעמה לע החינמ איה החנה וזיא הילא ? int func (int *arr, int n, int place, int val) { int i; if (place < 0 || place > n) return 0; for (i = n; i > place; i--) arr[i] = arr[i 1]; arr[place] = val; return 1; }
Background image of page 3

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

View Full DocumentRight Arrow Icon
האבה היצקנופה השוע המ ? ומכ - ןכ , הילא תרבעומש תזורחמה לע החינמ איה החנה וזיא ? #include <string.h> int secret (char *str) { int val, len; if (str[0]== '\0') return 0; len = strlen (str); val = str[len - 1] '0'; str[len - 1] = '\0'; return (val + secret(str)*10); }
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/10/2010 for the course CS 463 taught by Professor Can'tsay during the Spring '09 term at Haaga - Helia University of Applied Sciences.

Page1 / 15

rehearsal - :( structure) struct _Student cfw_ char *name;...

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

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