# include<iostream.h>
7. WAP to check whether a number is # include<conio.h>
armstrong or not void main( )
{
# include<iostream.h> int a[5][4],i,j;
# include<conio.h> for(i=0;i<5;i++)
void main( ) {
{ for(j=0;j<4;j++)
int n,d,s=0; }
cout<<"Enter a number:"; cout<<"Enter the elements:";
cin>>n; cin>>a[i][j]
int m=n; for(i=0;i<5;i++)
while(n!=0) {
{ for(j=0;j<4;j++)
d=n%10; }
s=s+(d*d*d); cout<<a[i][j];
n/=10; }
}
if(s==m) 10. WAP to input 5 numbers then find
cout<<"Armstrong:"; out the maximum and minimum
else values
Selection Sorting!
Concept to be
cout<<a[i][j]; understood!!!!
# include<iostream.h> }
# include<conio.h> }
void main( ) }
{
int a[5],s,l; 12. WAP to sort the array of 10
for(int i=0;i<5;i++) elements.
{
cout<<"Enter the elements"; # include<iostream.h>
cin>>a[i]; # include<conio.h>
s=l=a[0]; void main( )
} {
for(int i=1;i<=4;i++) int a[10],t=0,i,j;
{ for(i=0;i<10;i++)
if(a[i]>l) {
{ cout<<"Enter the value<<i+1<<"i";
l=a{i} cin>>a[i];
} }
else if(a[i]<s) for(i=0;i<10;i++)
{ {
s=a[i]; t=0;
} for(j=i;j<10;j++)
cout<<s<<l; {
} if([j]>t)
} {
t=a[j];
11. WAP to write 2D array and print }
values of all the elements. [i]=t;
}
# include<iostream.h> cout<<"Printed in desending order";
# include<conio.h> for(i=0;i<10;i++)
void main( ) {
{ cout<<"Values"<<i+1<<":"<<a[i];
int a[10][5],i,j; t=0;
for(i=0;i<10;i++) cout<<'Printed in desending order";
{ for(i=9;i>=0;i--)
for(j=0;j,5;j++) {
{ t=t+1;
cout<<"Enter the value"; cout<<"Values"<<t<<":"<<a[i];
cin>>a[i][j]; }
} }
}
for(i=0;i,10;i++) 13. WAP to find the number of vowels
{ in a string.
for(j=o;j,5;j==)
{ # include<iostream.h>
# include<string.h> }
# include<conio.h> }
void main( ) }
{
char s[80]; 15.WAP to replace every space in a
cout<<"Enter a string"; string with a hypen "_".
cin.getline(s,80); // to get a string of
length of maximum 80 charecters # include<iostream.h>
int vc=0; # include<string.h>
for(int i=0;s[i]!='\0';i++) # include<conio.h>
if(s[i]=='a'||s[i]=='A'||s[i]=='e'|| void main( )
s[i]=='E'||s[i]=='i'||s[i]=='I'||s[i]=='o'|| {
s[i]=='O'||s[i]=='u'||s[i]=='U') // char str[80];
checking for the presence of vowels cout<<"Enter the string";
vc++; // incrementation operator to cin.getline(str.80); // to get a string of
find the number of vowels(sum) length of maximum 80 charecters
cout<<vc; for(int i=0;str[i]!='\0';i++)
//vc=vc+1 {
} i(str[i]==' ') // ' ' =>Blankspace,
Cheking for blankspace
14. WAP to read the string if it is in string[i]='_'; // '_' => Hypen, convert
lowercase convert to uppercase if it blankspace to hypen
is in uppercase them print it is cout<<"Changed string is"<<str[i];
already in uppercase. }
}
# include<iostream.h>
# include<string.h> 16. WAP to read a password and print
# include<conio.h> Ok if the password is correct
void main( ) otherwise Sorry. Only three chances
{ are given to the user.
char str[25];
cout<<"Enter the string"; # include<iostream.h>
cin.getline(str,25); # include<string.h>
for(int i=0;str[i]!='\0;i++) # include<conio.h>
{ void main( )
if(isupper(str[i])) //isupper=> to {
check whether in uppercase or not char Pass[50];
{ cout<<"Enter the password";
cout<<"Already in uppercase" cin.getline(Pass,50); // to get string
} of maximum length of 50 charecters
else if(islower(str[i]) //islower=> to for(int i=0;i<3;i++)
check whether in lowercase or not {
{ if(strcmp(Pass,"SAI")!=0)
str[i]=toupper(str[i]); // to convert //strcmp=>String Compare
from lowercase to uppercase {
cout<<str[i]; cout<<Sorry";
}
else
cout<<"Ok";
break
}
}