Professional Documents
Culture Documents
TASK
Q1:: Write a program in C++ to read ‘n’ numbers from user then find and print all
prime numbers from these entered numbers.
PROGRAM
#include<iostream>
using namespace std;
int main(){ int n,i,j;
cout<<"enter number=";
cin>>n; for(i=2; i<n; i++)
{
#include<iostream>
using namespace std;
int main(){ int n,r;
cout<<"enter number="; cin>>n;
for(r=0; n!=0; n=n/10){
r=r*10; r=r+n%10;
}
cout<<"reverse"<<r<<endl; if(n==r){
cout<<r<<"is a palindrome numb";
}
else
{
cout<<r<<" is not a palindrome numb";
}
Write a program in C++ to print a string in reverse order. E.g., HOUSE will
be ESUOH.
PROGRAM
Q3:
#include<iostream>
#include<string.h>
using namespace std;
int main(){ char
ch[55]="sehar";
cout<<"change reverse string:"<<strrev(ch);
}
Write a program in C++ to count the prime number occurs within given range
by user.
PROGRAM
#include<iostream>
using namespace std;
int main(){ int num , i,
count,n; cout<<"enter
range:"; cin>>n;
Q4:
#include<iostream> using
namespace std; int main(){ int
rows,column,i,k; cout<<"enter
number of rows"; cin>>rows;
cout<<"enter number of column";
cin>>column; for(i=1; i<=rows; i+
+){ for(k=1; k<=column; k++)
{ cout<<"*";
Q5:
}
cout<<"\n";
}
}
• PART 2:
**
***
****
*****
******
PROGRAM:
#include<iostream>
rows,i,j;
cout<<"number of rows";
i++)
{ for(j=1; j<=i; +
+j){ cout<<"*";
} cout<<"\n";
• PART 3:
*
**
***
****
*****
PROGRAM:
#include<iostream>
string:"<<strrev
• PART 4:
*
***
****
******
********
*********
PROGRAM:
#include<iostream>
i++)
cout<<" ";
for(j=1; j<=(2*i-1);j++)
cout<<"*"; }
cout<<"\n";
• PART 5:
1
222
33333
4444444
5555555555
PROGRAM:
• PART 6:
1
212
32123
43214322
54321454321
PROGRAM: