-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmalloc_realloc.c
More file actions
41 lines (36 loc) · 871 Bytes
/
malloc_realloc.c
File metadata and controls
41 lines (36 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: main.c
* Author: onat
*
* Created on December 20, 2016, 9:54 AM
*/
#include <stdio.h>
#include <stdlib.h>
/*
*
*/
int main(int argc, char** argv) {
float ort=0;
int i=0;
int *sinifptr;
sinifptr=(int*) malloc(sizeof(int));
printf("islemi bitirmek icin -1 girin!!\n");
for(i=0;1;i++)
{
sinifptr=(int*)realloc(sinifptr,(i+1)*sizeof(int));
printf("%dnci ogrencinin notunu giriniz:\t", i+1);
scanf("%d", &sinifptr[i]);
if(sinifptr[i]==-1)
break;
ort= ort+sinifptr[i];
}
ort=ort/i;
printf("\n sinif ortalaması %.2f", ort);
free(sinifptr);
return (EXIT_SUCCESS);
}