C’de çift sayıları birer birer arttırma

#include 
void ciftArttir(int dizi[], int boyut)
{
	int i;
	
	for (i = 0; i < boyut; i++)
	{
		if (dizi[i] % 2 == 0)
		{
			dizi[i]++;
		}
	}
}

int main()
{
	int i,sayi[6] = { 1,2,3,4,5,6 };
	
	ciftArttir(sayi, 6);
	for (i = 0; i < 6; i++)
	{
		printf("%d\n", sayi[i]);
	}
	return 0;
}

ekran çıktısı
1
3
3
5
5
7
olacaktır.

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny