1 / 6

Understanding If Statements in C Programming

Learn how to use if statements in C to produce either a true (1) or false (0) value and execute specific code based on the condition. Various examples provided for practice.

Télécharger la présentation

Understanding If Statements in C Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The if statement

  2. if Şartlı kontrol • Koşul değimi doğru (1) yada yanlış (0) değeri üretir. • Şartın doğru olması durumunda if satırından sonraki değimler icra edilir. • Şartın yanlış değeri üretmesi durumunda else den sonraki değimler icra edilir.

  3. #include <stdio.h> int main(void) { int a, b, t; printf("Bir sayi giriniz:"); scanf("%d", &a); printf("Bir sayi giriniz:"); scanf("%d", &b); if (a < b) { t = a; a = b; b = t; printf("%d ile %d nin yerleri degistirildi\n", a, b); } else printf("%d buyuktur %d \n", a, b); return 0; }

  4. #include <stdio.h> int main() { int b; printf("Bir sayi giriniz:"); scanf("%d", &b); if (b < 0) printf("%d sayisi negatiftir \n", b); else if (b == 0) printf("Sayinin degeri sifir\n"); else printf("%d sayisi pozitiftir\n", b); return 0; }

  5. #include <stdio.h> int main() { int a; printf("Bir tam sayi giriniz:"); scanf("%d", &a); if ((a > 2) && (a < 4)) { printf ("a sayisi 3 (uc) \n"); } else printf("a sayisi 3 (uc) degil\n"); return 0; }

  6. #include <stdio.h> int main(void) { int a; printf("Bir tam sayi giriniz:"); scanf("%d", &a); if (a > 2) { if (a < 4) { printf ("a sayisi 3 (uc)\n"); } } else printf("a sayisi 3 (uc) degil\n"); return 0; }

More Related