-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcb_lec1.cpp
82 lines (77 loc) · 825 Bytes
/
cb_lec1.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include<iostream>
using namespace std;
void reverseNo(int n)
{
int k=0;
for(int i=0;n>0;i++)
{
k=k*10 + n%10;
n=n/10;
}
cout<<k<<" ";
cout<<endl;
}
void printPrimes(int n)
{
int i,j;
for(i=2;i<=n;i++)
{
for(j=2;j<i;j++)
{
if(i%j==0)
break;
}
if(j==i)
cout<<j<<" ";
}
}
void isPrime(int n)
{
int i;
for(i=2;i<n;i++)
{
if(n%i==0)
break;
}
if(i==n)
cout<<"prime\n";
else
cout<<"not prime\n";
}
void f1()
{
int i,j;
for(i=1;i<=5;i++)
{
int k=1,m=0;
for(j=1;j<=5;j++)
{
if(j<=i)
{
if(i%2==0)
{
cout<<m<<" ";
m=1-m;
}
else
{
cout<<k<<" ";
k=1-k;
}
}
else
cout<<" ";
}
cout<<endl;
}
}
int main()
{
int n;
cout<<"Enter a no\n";
cin>>n;
reverseNo(n);
// printf("Sukhdeep\n");
cout<<endl;
return 0;
}