By Switch
By Switch
70067973
SECTION – T
switch(num)
{
case 1:
{
int a,b;
cout<<"Enter a Base =";
cin>>a;
cout<<"Enter a power =";
cin>>b;
cout<<pow(a,b);
}
break;
case 2:
{
int n, c, a= 0, b= 1, d;
cout <<"Enter the number of terms of Fibonacci series"<< endl;
cin >> n;
for ( c = 0 ; c < n ; c++ )
{
if ( c <= 1 )
d=c;
else
{
d=a+b;
a=b;
b=next;
}
cout<<d<<endl;
}
}
break;
case 3:
{
int x;
cout<<"Enter the number =";
cin>>x;
for(int i=2;i<x;i++)
{
if(x%i==0)
{
cout<<"Not Prime";
}
}
}
break;
case 4:
{
int a,b;
cout<<"Enter a Number =";
cin>>a;
if(a%2==0)
{
cout<<"Number is Even";
}
else
{
cout<<"Number is odd";
}
}
break;
case 5:
{
float attendance,total=32,a;
cout<<"Enter Attendance =";
cin>>attendance;
a=(attendance/total)*100;
cout<<"Percentage of student attendance ="<<a<<endl;
if(a<75)
{
cout<<"Not allow ";
}
else
{
cout<<"Allow ";
}
}
break;
case 6:
{
int a,b,sum;
cout<<"Enter first number =";
cin>>a;
cout<<"Enter second number =";
cin>>b;
sum=a+b;
cout<<"sum is "<<sum<<endl;
}
break;
case 7:
{
int a,b,Sub;
cout<<"Enter first number =";
cin>>a;
cout<<"Enter second number =";
cin>>b;
Sub=a-b;
cout<<"Sub is "<<Sub<<endl;
}
break;
case 8:
{
int a,b,Mult;
cout<<"Enter first number =";
cin>>a;
cout<<"Enter second number =";
cin>>b;
Mult=a*b;
cout<<"Mult is "<<Mult<<endl;
}
break;
case 9:
{
int a,b,Div;
cout<<"Enter first number =";
cin>>a;
cout<<"Enter second number =";
cin>>b;
Div=a/b;
cout<<"Div is "<<Div<<endl;
}
break;
case 0:
{
if(num==0)
{
break;
}
}