Skip to content

Commit c15e100

Browse files
authored
Add files via upload
1 parent c3a8317 commit c15e100

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

do_while.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*exp6_2-Using do-while loop*/
2+
# include <iostream>
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int i=1;
8+
do
9+
{
10+
cout<<i++<<" ";
11+
}
12+
while(i<=50);
13+
}

for_loop.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*exp6_3-Using for loop*/
2+
# include <iostream>
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int i;
8+
for(i=0;i<10;i++) /*to print hello world 10 times*/
9+
{
10+
cout<<"hello world"<<endl;
11+
}
12+
}

number_triangle.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*exp6_4-Using for loop to print a number triangle*/
2+
#include <iostream>
3+
using namespace std;
4+
int main()
5+
{
6+
int i,j,k,l,n;
7+
cout<<"Enter the number of Rows=";
8+
cin>>n;
9+
for(i=1;i<=n;i++)
10+
{
11+
for(j=1;j<=n-i;j++)
12+
{
13+
cout<<" ";
14+
}
15+
for(k=1;k<=i;k++)
16+
{
17+
cout<<k;
18+
}
19+
for(l=i-1;l>=1;l--)
20+
{
21+
cout<<l;
22+
}
23+
cout<<"\n";
24+
}
25+
return 0;
26+
}

while.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*Exp-6-Loops in C++*/
2+
/*exp6_1-Using while loop*/
3+
# include <iostream>
4+
using namespace std;
5+
6+
int main()
7+
{
8+
int i=1;
9+
while(i<=50)
10+
{
11+
cout<<i++<<" ";
12+
}
13+
}

0 commit comments

Comments
 (0)