Skip to content

Commit 7230bad

Browse files
authored
Add files via upload
1 parent 40b702a commit 7230bad

23 files changed

+331
-0
lines changed

10 - loops/for infinte loop.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main() {
4+
// for (int i=0;;i++) {
5+
// if(i==2){
6+
// continue;
7+
// }
8+
// if(i==400) {
9+
// break;
10+
// }
11+
// cout<<i<<endl;
12+
// }
13+
int i=0;
14+
for(;;) {
15+
cout<<++i;
16+
}
17+
}

10 - loops/for loop pattern.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main () {
4+
int x, y;
5+
for (x=0; x<5; x++) {
6+
for(y=0; y<x+1; y++) {
7+
cout<<"* ";
8+
}
9+
cout<<endl;
10+
}
11+
cout<<"\n";
12+
for(x=0; x<5; x++) {
13+
for(y=5; y>x; y--) {
14+
cout<<"* ";
15+
}
16+
cout<<endl;
17+
}
18+
}

10 - loops/for loop.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main() {
4+
int value;
5+
cout<<"Enter the number : ";
6+
cin>>value;
7+
//for loop
8+
// for(int i=1; i<=10; i++) {
9+
// cout<<i*value<<"\n";
10+
// }
11+
12+
// for(int i =10; i>0; i--) {
13+
// cout<<i*value<<endl;
14+
// }
15+
int i;
16+
for(i=0; i<5; i++);
17+
cout<<i;
18+
19+
return 0;
20+
}

10 - loops/while loop.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main() {
4+
int sum=0, i=1;
5+
do {
6+
sum+=i++;
7+
} while(i<=4);
8+
cout<<"Sum is : "<<sum<<endl;
9+
cout<<i<<endl;
10+
return 0;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main() {
4+
int arr[3];
5+
arr[0] = 10;
6+
arr[1] = 20;
7+
arr[2] = 30;
8+
for(int i=0; i<3; i++)
9+
cout<<arr[i]<<"\t";
10+
return 0;
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main() {
4+
// int arr[10] = {10, 20, 30};
5+
int arr[] = {10, 20, 30};
6+
for(int i=0; i<3; i++)
7+
cout<<arr[i]<<"\t";
8+
return 0;
9+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main() {
4+
int size = 5, i=0;
5+
int arr[5];
6+
cout<<"Enter the values : \n";
7+
for(i=0; i<size; i++) {
8+
cin>>arr[i];
9+
}
10+
int min=arr[0], max=arr[0];
11+
for(i=0; i<size; i++) {
12+
if(min>arr[i])
13+
min=arr[i];
14+
if(arr[i]>max)
15+
max=arr[i];
16+
}
17+
cout<<"Minimum number is : "<<min<<endl;
18+
cout<<"Maximum number is : "<<max<<endl;
19+
return 0;
20+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <iostream>
2+
3+
//HELLO WORLD
4+
5+
using namespace std;
6+
int main() {
7+
cout<<"Hello World";
8+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <iostream>
2+
3+
namespace demo {
4+
int a = 5;
5+
void show() {
6+
std::cout<<"ShreyYash"<<std::endl;
7+
}
8+
}
9+
using namespace demo;
10+
int main() {
11+
show();
12+
std::cout<<demo::a;
13+
return 0;
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main() {
4+
cout<<"I\'m",
5+
cout<<" doing",
6+
cout<<" C++",
7+
cout<<" Programming";
8+
return 0;
9+
}

0 commit comments

Comments
 (0)