1 2 3 4 5 6 7 8 9 10 11 12 13 |
#include <conio.h> #include <iostream.h> main(){ unsigned long x; int y=1; cout<<"Pozitif bir tam sayi girin:"; cin>>x; for(long i=0; i<x; i++) y*=-1; cout<<"Girilen sayi "<<(y==1?"cift":"tek"); getch(); } |
1 2 3 4 5 6 7 8 9 10 11 |
#include <conio.h> #include <iostream.h> main(){ unsigned long x; int y=1; cout<<"Pozitif bir tam sayi girin:"; cin>>x; cout<<"Girilen sayi "<<(x==(int)(x*0.5)*2?"cift":"tek"); getch(); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include <conio.h> #include <iostream.h> main(){ unsigned long sayi=0, s; int kontrol=0; cout<<"Pozitif bir tam sayi girin:"; cin>>sayi; for (int i = 0; i <= sayi; i++) { s=i*2; if(s==sayi) kontrol=1; } cout<<"Girilen sayi "; if(kontrol==1) cout<<"cift"; else cout<<"tek"; getch(); } |