Professional Documents
Culture Documents
Program to display
pattern
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char a,b;
a=65;
for(int i =1;i<10;i++)
{
for(int u=0;u<i;u++)
{
cout<<char(a+u);
}
cout<<endl;
}
getch();
}
2.Program to display
pattern
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
for(int i=1;i<10;i++)
{
for(int uu=7;uu>=3;uu--)
cout<<"*";
for(int yyy=10;yyy>=i;yyy-=1)
cout<<" ";
for(int uuu=7;uuu>=3;uuu--)
cout<<"*";
for(int yy1=10;yy1<=i+10;yy1++)
cout<<" ";
for(int uu1=7;uu1>=3;uu1--)
cout<<"*";
for(int yyy1=10;yyy1>=i;yyy1-=1)
cout<<" ";
for(int uuu1=7;uuu1>=3;uuu1--)
cout<<"*";
cout<<endl;
}
for(int ii=1;ii<10;ii++)
{
for(int uu=7;uu>=3;uu--)
cout<<"*";
for(int yyy=0;yyy<=ii;yyy++)
cout<<" ";
for(int uuu=7;uuu>=3;uuu--)
cout<<"*";
for(int yy1=10;yy1>=ii;yy1--)
cout<<" ";
for(int uu1=7;uu1>=3;uu1--)
cout<<"*";
for(int yyy1=0;yyy1<=ii;yyy1++)
cout<<" ";
for(int uuu1=7;uuu1>=3;uuu1--)
cout<<"*";
cout<<endl;
}
getch();
}
case'2':peri=2*(l+b);
cout<<"Perimeter "<<peri;
break;
case'3':diag=sqrt((l*l)+(b*b));
cout<<"Diagonal "<<diag;
break;
case'4':cout<<"Breaking";
break;
default:cout<<"Wrong choice";
cout<<"Enter a valid one";
break;
}
cout<<"Want to enter more ???";
cin>>ch1;
if(ch1=='y'||ch1=='Y')
cout<<"Again enter choice";
}while(ch1=='y'||ch1=='Y');
getch();
}
float a,b,c,big,big2,big3;
cout<<"Enter three numbers";
cin>>a>>b>>c;
big=a;
if(b>big)
big=b;
if(c>big)
big=c;
if(a==big)
{
if(b>c)
{
big2=b;
big3=c;
}
else
{
big2=c;
big3=b;
}
}
else if(b==big)
{
if(a>c)
{
big2=a;
big3=c;
}
else
{
big2=c;
big3=a;
}
}
else if(c==big)
{
if(a>b)
{
big2=a;
big3=b;
}
else
{
big2=b;
big3=a;
}
}
cout<<big<<" "<<big2<<" "<<big3<<endl;
getch();
}
#include<stdio.h>
#include<math.h>
void main()
{
clrscr();
int chcount=0;
const char ent='\n';
char ch;
cout<<"Enter character";
cin.get(ch);
while(ch!=ent)
{
if(ch>='a'&&ch<='z')
{
chcount++;
cout.put(ch);
}
cin.get(ch);
}
cout<<"the number of character ="<chcount<<'\n';
getch();
}
int i, j, k;
int A[5], B[5], C[10];
cout<<"Enter array A:";
for(i=0; i<5; i++)
cin>>A[i];
cout<<"Enter array B:";
for(j=0;j<5;j++)
cin>>B[j];
for(i=0,k=0; i<5;k++, i++)
C[k]=A[i];
for(k=5, i=0; i<5; k++, i++)
C[k]=B[i];
cout<<"\nArray C:";
for(k=0;k<10;k++)
cout<<C[k]<<" ";
getch();
}
{
for(i=8; i>=0; i--)
{
if(arr[i]==0)
{
for(int j=i;j>0;j--)
{
t=arr[j];
arr[j]=arr[j-1];
arr[j-1]=t;
}
}
}
}
cout<< "Array after replacing "<<n<<": ";
for(i=0; i<9; i++)
cout<<arr[i];
getch();
}
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
struct Student
{
int rollno;
char name[21];
float marks[5];
char grade;
};
Student learner;
void main()
{
clrscr();
cout<<"Enter Roll No: ";
cin>>learner.rollno;
cout<<"Enter Name ";
gets(learner.name);
cout<<"Enter marks in 5 subjects"<<endl;
for(int i=0;i<5;i++)
{
cout<<"Subject"<<i+1;
cin>>learner.marks[i];
}
float avg,total;
total=(learner.marks[0]+learner.marks[1]+learner.marks[2]+learner.marks[3]+lear
ner.marks[4]);
avg=total/5;
cout<<"Student result"<<endl;
cout<<"Roll No:"<<learner.rollno<<"\t";
cout<<"Name";
cout.write(learner.name,21);
cout<<"Total Marks"<<total;
cout<<"Average"<<avg;
getch();
}
cout<<"Total incehs"<<l3.inches<<endl;
getch();
}