0% found this document useful (0 votes)
13 views1 page

Using Namespace Int: #Include

1. The document declares variables to store an array of 50 integers input by the user, its size n, indexes i and j, a variable to count prime numbers, and other variables. 2. It checks if all numbers in the array are prime by testing their factors, and prints a message. 3. It then checks if any number in the array is a palindrome by reversing its digits, and prints the first palindrome found.

Uploaded by

Radu Verga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Using Namespace Int: #Include

1. The document declares variables to store an array of 50 integers input by the user, its size n, indexes i and j, a variable to count prime numbers, and other variables. 2. It checks if all numbers in the array are prime by testing their factors, and prints a message. 3. It then checks if any number in the array is a palindrome by reversing its digits, and prints the first palindrome found.

Uploaded by

Radu Verga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

#include <iostream>
using namespace std;
int main()
{
int v[50],n,test,i,prim=0,j,copie,c,rasturnat=0;
cout<<"n=";
cin>>n;
for(i=0;i<=n-1;i++)
{
cout<<"v["<<i+1<<"]=";
cin>>v[i];
}
for(i=0;i<=n-1;i++)
{
test=1;
for(j=2;j<=v[i]/2;j++)
if(v[i]%j==0)
test=0;
if(test==1)
prim++;
}
if(prim==n)
cout<<"Toate numerele sunt prime"<<endl;
else
cout<<"Toate numerele nu sunt prime"<<endl;
for(i=0;i<=n-1;i++)
{
copie=v[i];
while(copie)
{
c=copie%10;
rasturnat=rasturnat*10+c;
copie=copie/10;
}
if(v[i]==rasturnat)
cout<<"Exista un numar palindrom "<<v[i];
else
break;
}
}

You might also like