7 Ağustos 2015 Cuma

Karar Yapıları Örnek Sorular

Konsoldan okunan bir sayının 10 değerine göre durumu (büyük,küçük,eşit)
#include<iostream>
using namespace std;
void main ()
{ int x;
cout<<"x:";cin>>x;
if(x<10)
cout<<"x kucuktur 10'dan"<<endl;
else if(x>10)
cout<<"x buyuktur 10'dan"<<endl;
else
cout<<"x esittir 10'a "<<endl;
}
#include<iostream>
using namespace std;
void main ()
{ int x,y;
cout<<"x:";cin>>x;
cout<<"y:";cin>>y;
if(x<y)
cout<<"x kucuktur y"<<endl;
else if(x>y)
cout<<"x buyuktur y"<<endl;
else
cout<<"x esittir y"<<endl;

}

#include<iostream>
using namespace std;
void main ()
{  double ort,x,y;//x vize y final
cout<<"vize notu gir:   ";cin>>x;
cout<<"final notu gir:   ";cin>>y;
   ort=(x*4)/10+(y*6)/10;
   if(ort>=50)
       cout<<"gectiniz"<<"\t"<<ort<<endl;
   else
       cout<<"kaldiniz"<<"\t"<<ort<<endl;
}

#include<iostream>
using namespace std;
void main ()
{  double x;
cout<<"x:";cin>>x;
if(x<0 || x>100 )
cout<<"hayir"<<endl;
else
cout<<"evet"<<endl;


}


#include<iostream>
using namespace std;
void main ()
{  double x;
cout<<"x:";cin>>x;
if(x>0 && x<100 )
cout<<"hayir"<<endl;
else
cout<<"evet"<<endl;
}

#include<iostream>
using namespace std;
void main ()
{  double x;
cout<<"kac derece : ";cin>>x;
if(x<0)
cout<<"Soguk"<<endl;
else if(x>15)
cout<<"sicak"<<endl;
else
cout<<"ilik"<<endl;
}


#include<iostream>
using namespace std;
void main ()
{  int x,y;
cout<<"x : ";cin>>x;
cout<<"y : ",cin>>y;
bas:
x=x+1;
if(x<y)
{cout<<x<<endl;
goto bas;}
else(y<x);
 y++;
cout<<y<<endl;
}


#include<iostream>
using namespace std;
void main ()
{  int a,b,top=0;
cin>>a>>b;
art:if(a<b)
  a++;
top=top+a;
cout<<top<<endl; goto art;
}


#include<iostream>
using namespace std;
void main()
{  int n,sayi,sayac=0,top=0;
cout<<"sayi adeti:";cin>>n;
oku:
cout<<"sayi giriniz:   ";cin>>sayi;
top=top+sayi;
sayac=sayac+1;
if (sayac<n)goto oku;
cout<<"ortalama:"<<"\t"<<(top/n)<<endl;
}

Hiç yorum yok:

Yorum Gönder