CaCao
07/10/2007, 17:30
merhaba
ilk programda 12 ayin sicaklik degerlerini giriyorsunuz bunda size
*toplam sicakligin ortalamasini,
*enyuksek sicakligin hangi ayda oldugunu
*kac tane sicakligin toplam sicaklik ortalamasindan buyuk oldugunu program vericek fakat bende ortalama kisminda bi hata veriyor bulamadim hatanin ne oldugunu bi bakabilirseniz sevinirim...
sonucun su cikmasi gerekiyor:
1.ay:5
2 : 1
3: 8
4: 15
5: 20
6: 25
7: 30
8: 40
9: 35
10: 22
11: 15
12: 5
Yearly avarage: 18.4-------- (bende 18 veriyor)
Max. Temp. is 40 in month 8.
There are 6 months above the avg. temp.
#include <stdio.h>
#include <stdlib.h>
#define SIZE 12
/****************Function Avarage*********************/
double avarage(int ary[], int size)
{
int i, total;
double avg;
//initilaizing
total=0; avg=0;
i=0;
//find the total teprature
for(i=0;i<size;i++)
total=total+ary[i];
//find the avarage of temratures
avg=total/size;
//return avarage
return(avg);
}
/********************Function Max_Month**************/
int max_month(int ary[],int size)
{
int i,
num,
max;
//initializing
i=0; num=0; max=0;
max=ary[1];
//find the maximum temp.
for(i=0;i<size;i++)
{
if(ary[i]>max)
{
max=ary[i];
num=i;
}
}
//return number
return(num);
}
/**************Function Count_above************/
int count_above(int ary[], int size)
{
//declaration
int i,
count;
double avg;
//initialize the count
count=0;
//call avarage fuction
avg=avarage(ary,size);
//find how many temp. are above the avarage
for(i=0;i<size;i++)
{
if(ary[i]>avg)
{
count++;
}
}
//return the total
return(count);
}
/****************MAIN**************************/
int
main(void)
{
//declaration
int ary[SIZE], //array
i, //array's loop
max=0, //maximum temp.
count=0; //count of temp. that are above the avg.
double avg; //avarage
//get the tempratures of each month in a year
for(i=0;i<SIZE;i++)
{
printf("Enter the temprature %d month: ",i+1);
scanf("%d",&ary[i]);
}
//call avarage funtion
avg=avarage(ary,SIZE);
//display the avarage of temprature
printf("\nYearly avarage = %.f",avg);
//call max_month function
max=max_month(ary,SIZE);
//display the maximum temprature and its month
printf("\nMaximum Teprature is %d in mounth %d ",ary[max],max+1);
//call count_above function
count=count_above(ary,SIZE);
//display how many month's teprature are greater than avarage
printf("\nThere are %d months above the avarage temprature.",count);
system("pause");
return(0);
}
______________
ikinci sorum baska bir programla ilgilii =)
burdada istediginiz bir harfle bir isaretin yer degistirmesi bende ilk girdigim harfi vermiyor garip bi sekil veriyor :(
soyle olmali:
Enter the array elements * to exit:
T
U
R
K
I
Y
E
*
Pls enter symbol to be replaced in an array: I
pls enter symbol to be replaced with the symbol: ?
TURK?YE
boyle olcak program =)
#include <stdio.h>
#include <stdlib.h>
#define SIZE 20
int
main(void)
{
char ary[SIZE],
chr,
sym;
int i,j,count;
/*get the elements in an array*/
printf("Enter the array elements, * to exit:\n");
scanf(" %c",&ary[i]);
i=0;
//control the elements
while(ary[i]!='*' && i<SIZE)
{
i++;
scanf(" %c",&ary[i]);
}
//get the element
printf("\nPlease enter symbol to be replaced in an array:");
scanf(" %c",&chr);
//get the symbol
printf("\nPlease enter symbol to be replaced with this symbol:");
scanf(" %c",&sym);
//replace the element with symbol
for(j=0;j<i;j++)
{
if(ary[j]==chr)
{
ary[j]=sym;
count++;
}
}
//print the letters
for(j=0;j<i;j++)
printf(" %c",ary[j]);
//display the result
printf("\nNumber of replacement: %d",count);
system("pause");
return(0);
}
yardimlarinizi bekliyorumm...
ilk programda 12 ayin sicaklik degerlerini giriyorsunuz bunda size
*toplam sicakligin ortalamasini,
*enyuksek sicakligin hangi ayda oldugunu
*kac tane sicakligin toplam sicaklik ortalamasindan buyuk oldugunu program vericek fakat bende ortalama kisminda bi hata veriyor bulamadim hatanin ne oldugunu bi bakabilirseniz sevinirim...
sonucun su cikmasi gerekiyor:
1.ay:5
2 : 1
3: 8
4: 15
5: 20
6: 25
7: 30
8: 40
9: 35
10: 22
11: 15
12: 5
Yearly avarage: 18.4-------- (bende 18 veriyor)
Max. Temp. is 40 in month 8.
There are 6 months above the avg. temp.
#include <stdio.h>
#include <stdlib.h>
#define SIZE 12
/****************Function Avarage*********************/
double avarage(int ary[], int size)
{
int i, total;
double avg;
//initilaizing
total=0; avg=0;
i=0;
//find the total teprature
for(i=0;i<size;i++)
total=total+ary[i];
//find the avarage of temratures
avg=total/size;
//return avarage
return(avg);
}
/********************Function Max_Month**************/
int max_month(int ary[],int size)
{
int i,
num,
max;
//initializing
i=0; num=0; max=0;
max=ary[1];
//find the maximum temp.
for(i=0;i<size;i++)
{
if(ary[i]>max)
{
max=ary[i];
num=i;
}
}
//return number
return(num);
}
/**************Function Count_above************/
int count_above(int ary[], int size)
{
//declaration
int i,
count;
double avg;
//initialize the count
count=0;
//call avarage fuction
avg=avarage(ary,size);
//find how many temp. are above the avarage
for(i=0;i<size;i++)
{
if(ary[i]>avg)
{
count++;
}
}
//return the total
return(count);
}
/****************MAIN**************************/
int
main(void)
{
//declaration
int ary[SIZE], //array
i, //array's loop
max=0, //maximum temp.
count=0; //count of temp. that are above the avg.
double avg; //avarage
//get the tempratures of each month in a year
for(i=0;i<SIZE;i++)
{
printf("Enter the temprature %d month: ",i+1);
scanf("%d",&ary[i]);
}
//call avarage funtion
avg=avarage(ary,SIZE);
//display the avarage of temprature
printf("\nYearly avarage = %.f",avg);
//call max_month function
max=max_month(ary,SIZE);
//display the maximum temprature and its month
printf("\nMaximum Teprature is %d in mounth %d ",ary[max],max+1);
//call count_above function
count=count_above(ary,SIZE);
//display how many month's teprature are greater than avarage
printf("\nThere are %d months above the avarage temprature.",count);
system("pause");
return(0);
}
______________
ikinci sorum baska bir programla ilgilii =)
burdada istediginiz bir harfle bir isaretin yer degistirmesi bende ilk girdigim harfi vermiyor garip bi sekil veriyor :(
soyle olmali:
Enter the array elements * to exit:
T
U
R
K
I
Y
E
*
Pls enter symbol to be replaced in an array: I
pls enter symbol to be replaced with the symbol: ?
TURK?YE
boyle olcak program =)
#include <stdio.h>
#include <stdlib.h>
#define SIZE 20
int
main(void)
{
char ary[SIZE],
chr,
sym;
int i,j,count;
/*get the elements in an array*/
printf("Enter the array elements, * to exit:\n");
scanf(" %c",&ary[i]);
i=0;
//control the elements
while(ary[i]!='*' && i<SIZE)
{
i++;
scanf(" %c",&ary[i]);
}
//get the element
printf("\nPlease enter symbol to be replaced in an array:");
scanf(" %c",&chr);
//get the symbol
printf("\nPlease enter symbol to be replaced with this symbol:");
scanf(" %c",&sym);
//replace the element with symbol
for(j=0;j<i;j++)
{
if(ary[j]==chr)
{
ary[j]=sym;
count++;
}
}
//print the letters
for(j=0;j<i;j++)
printf(" %c",ary[j]);
//display the result
printf("\nNumber of replacement: %d",count);
system("pause");
return(0);
}
yardimlarinizi bekliyorumm...