You are on page 1of 16

Program No.

8
Input:#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int choice,r;
float area,perimeter;
cout<<"\n circle menu:";
cout<<"\n \n \t 1. Area of circle";
cout<<"\n \t 2. Perimeter of circle";
cout<<"\n \n Enter your choice(1-2) ";
cin>>choice;
if(choice==1)
{
cout<<"\n Enter the radius of circle: ";
cin>>r;
area=3.14*r*r;
cout<<"\n The area of circle is:"<<area;
}
else
{

cout<<"\n Enter the radius of circle:";


cin>>r;
perimeter=2*3.14*r;
cout<<"\n The perimeter of circle is:"<<perimeter;
}
getch();
}

Output:-

Program No. 9
Input:#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char ch='A';
int n;
cout<<"\n Enter the height of the triangle:";
cin>>n;

cout<<"\n ";
for(int i=1;i<=n;i++)
{ ch='A';
for(int j=1;j<=i;j++)
{
cout<<ch<<" ";
ch++;}
cout<<"\n "; }
getch();
}

Output:-

Program No. 10
Input:#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
int t=0,r=0,x,y,i;
cout<<"\n Enter top:";
cin>>t;
cout<<"\n Enter rows:";
cin>>r;
cout<<"\n";
for(x=0;x<r;x++)
{ for(y=t-(x*2);y>0;y--)
cout<<"&";
cout<<"\n";
for(i=0;i<x+1;i++)
cout<<" ";
}
getch();
}

Output:-

Program No. 11
Input:#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
int first,second,third,n,i;
first=0;
second=1;
cout<<"\t How many elements? \n";
cout<<"\t";
cin>>n;
cout<<"\n \t Fibonacci series: \n";
cout<<"\t"<<first<<" "<<second;
for(i=2;i<n;++i)
{
third=first+second;
cout<<" "<<third;
first=second;
second=third;
}
getch();
}

Output:-

Program No. 12
Input:#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int long num,r,sum=0,t;
cout<<"Enter a number:";
cin>>num;
for(t=num;num!=0;num=num/10)
{
r=num%10;
sum=sum*10+r;
}
if(t==sum)
cout<<t<<" is a palindrome";
else
cout<<t<<" is not a palindrome";
getch();
}

Output:-

Program No. 13
Input:#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{ clrscr();
int i,n,sign=-1;
float a=2,b=9;
cout<<"Enter the number of terms in the series:";
cin>>n;
float sum=a/b;
for(i=1;i<=n;i++)
{
cout<<a<<"/"<<b<<" "<<sign<<" "<<endl;
a=a+3;
b=b+4;
sign=-1*sign;
sum+=sign*(a/b);
}
cout<<"\n the sum of the series is = "<<sum;
getch();
}

Output:-

Program No. 14
Input:#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{ clrscr();
char s[50];
int w=0,chr=0,space=0,i;
cout<<"\n Enter a string:";
cin>>s;
for(i=0;s[i]!='\0';i++)
{
if(s[i]==' ')
space++;
}
chr=strlen(s)-space;
w=space+1;
cout<<"\n The total no. of words ="<<w;
cout<<"\n Thr total characters without spaces ="<<chr;
getch();
}

Output:-

You might also like