Skip to content

Commit 110c318

Browse files
Merge pull request #20 from HelloWorldGTBIT/master
count.cpp
2 parents 621a5f1 + 0d1ad0d commit 110c318

15 files changed

Lines changed: 210 additions & 1 deletion

Factorial in C

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdio.h>
2+
3+
int factorial(int number)
4+
{
5+
if(number == 0){
6+
return 1;
7+
}
8+
return number * factorial(number-1);
9+
}
10+
11+
int main(){
12+
printf("%d\n", factorial(10));
13+
return 0;
14+
}

Factorial using recursion

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdio.h>
2+
3+
int factorial(int number)
4+
{
5+
if(number == 0){
6+
return 1;
7+
}
8+
return number * factorial(number-1);
9+
}
10+
11+
int main(){
12+
printf("%d\n", factorial(10));
13+
return 0;
14+
}

Pattern.cpp

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

Q21.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# fibonacci series
2+
num1 = eval(input(' Enter number of terms '))
3+
FN = 0 ; SN = 1
4+
print(FN)
5+
print(SN)
6+
for i in range(2, num1):
7+
TN = FN + SN
8+
print(TN)
9+
FN = SN
10+
SN = TN
11+
i += 1
12+

base.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
#Code File
22

3+
def printing():
4+
print("hello world")
5+
6+
def hellowrol ():
7+
return"hello world"
8+
print(hellowrol ())
9+
10+
void x()
11+
{
12+
cout<<"Hello World";
13+
}
14+
15+
def m():
16+
print "HelloWorld"
17+
318
def helloWorld():
4-
return "Hello World"
19+
return "Hello World"
20+

count.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include<iostream>
2+
using namespace std;
3+
int i=10;
4+
int main(){
5+
char c;
6+
int numCount = 0;
7+
int alphaCount = 0;
8+
int spaceCount = 0;
9+
//cin>>c;
10+
c = cin.get();
11+
while(c!='$'){
12+
if(c==' ' || c=='\t' || c=='\n'){
13+
spaceCount++;
14+
}
15+
else if(c>='0' && c<='9'){
16+
numCount++;
17+
}
18+
else if((c>='A' && c<='Z') || (c>='a' && c<='z')){
19+
alphaCount++;
20+
}
21+
//cin>>c;
22+
c = cin.get();
23+
}
24+
cout<<spaceCount<<endl;
25+
cout<<numCount<<endl;
26+
cout<<alphaCount<<endl;
27+
}

createprintpattern.cpp

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

fb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
num1 = eval(input(' Enter number of terms '))
2+
FN = 0 ; SN = 1
3+
print(FN)
4+
print(SN)
5+
for i in range(2, num1):
6+
TN = FN + SN
7+
print(TN)
8+
FN = SN
9+
SN = TN
10+
i += 1
11+
num1 = eval(input(' Enter number of terms '))
12+
FN = 0 ; SN = 1
13+
print(FN)
14+
print(SN)
15+
for i in range(2, num1):
16+
TN = FN + SN
17+
print(TN)
18+
FN = SN
19+
SN = TN
20+
i += 1

patt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
for i in range(1,n):
2+
print ("*"*i)

pattern.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
for i in range(1,n):
2+
print ("*"*i)

0 commit comments

Comments
 (0)