Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
fb7ca2f
Create factorial.py
akku710 Oct 2, 2020
37c526a
Create README.md
akku710 Oct 2, 2020
5d6c7c0
Create prime number.py
akku710 Oct 2, 2020
f6b46b8
Create README.md
akku710 Oct 2, 2020
cfc92dd
Delete prime number.py
akku710 Oct 2, 2020
7b73ee0
Update README.md
akku710 Oct 2, 2020
8296e95
Delete README.md
akku710 Oct 2, 2020
941b031
Create program.c
gilbertraju Oct 3, 2020
18bfadb
Create program.c
gilbertraju Oct 3, 2020
ecda4af
Check a number is prime or not
akku710 Oct 3, 2020
4d634f1
added pattern.py
mahi252001 Oct 3, 2020
296738c
added pattern2.py
mahi252001 Oct 3, 2020
07e74b9
added pattern3.py
mahi252001 Oct 3, 2020
444a9cd
added program8.py
mahi252001 Oct 3, 2020
62003c1
added program
nireekshamn Oct 3, 2020
6435904
added second program
nireekshamn Oct 3, 2020
397dba0
Merge pull request #112 from aakashjain71098/aakash
swaaz Oct 3, 2020
445c51d
Merge pull request #131 from swaaz/hacktoberfest
swaaz Oct 3, 2020
956ab0e
Merge pull request #117 from gilbertraju/third
swaaz Oct 3, 2020
2e73acf
Merge pull request #132 from swaaz/hacktoberfest
swaaz Oct 3, 2020
0dadc21
Check whether number is prime or not.
akku710 Oct 3, 2020
5e4e5b5
Program to calculate factorial of a number in C++
prajnakalpa Oct 3, 2020
ae92467
Merge pull request #135 from swaaz/hacktoberfest
swaaz Oct 3, 2020
f90c56b
Merge pull request #136 from swaaz/hacktoberfest
swaaz Oct 3, 2020
38c6c04
added readme.md
mahi252001 Oct 4, 2020
69a68e4
added readme.md
mahi252001 Oct 4, 2020
097b277
Delete pattern1.py
swaaz Oct 4, 2020
82258d5
Rename pattern2.py to pattern.py
swaaz Oct 4, 2020
08a6fe8
Merge pull request #127 from mahi252001/mahima2
swaaz Oct 4, 2020
103b38c
Merge pull request #128 from nireekshamn/nireeksha1
swaaz Oct 4, 2020
164a892
Rename Python/program-16/shufflecards.py to Python/program-11/shuffle…
swaaz Oct 4, 2020
5abc35d
Merge pull request #130 from nireekshamn/nireeksha3
swaaz Oct 4, 2020
83da926
Merge pull request #133 from aakashjain71098/aakash1
swaaz Oct 4, 2020
f17546e
Merge pull request #134 from prajnakalpa/master
swaaz Oct 4, 2020
1fd6544
add my python file
keerthika15 Oct 5, 2020
f23a705
add my python file
keerthika15 Oct 5, 2020
7dc569d
add my python file
keerthika15 Oct 5, 2020
9842254
add my python file
keerthika15 Oct 5, 2020
1eea1d8
Merge pull request #153 from swaaz/master
swaaz Oct 5, 2020
13bf5e4
added gif
swaaz Oct 5, 2020
c52c699
Merge pull request #154 from swaaz/swaaz
swaaz Oct 5, 2020
3e8f4ed
Merge pull request #151 from keerthika15/key3
swaaz Oct 5, 2020
89d971e
Merge pull request #1 from swaaz/master
RahulRao23 Oct 5, 2020
f290af5
updated README.md
RahulRao23 Oct 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions C++/Program-4/factorial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
int n,size=200,fact[size],j=size-1,carry=0;
cin>>n;
fact[size-1]=1;
while(n>1){
int x;
for(int k=size-1;k>=j;k--){
x=fact[k]*n+carry;
fact[k]=x%10;
carry=x/10;}
while(carry>0){
fact[--j]= carry%10;
carry/=10;}
n--;
}
for(int k=j;k<size;k++){
cout<<fact[k];
}
cout<<endl;
}
return 0;
}

1 change: 1 addition & 0 deletions C++/Program-4/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Program to find factorial of a number
23 changes: 23 additions & 0 deletions C/program-61/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include<stdio.h>
void main()
{
double r,area,circum;//Initializing varaibles

printf("Enter Radius:");
scanf("%lf",&r);//getting radius.

if(r<10)//Checks if radius is less than 10
{
circum = 2*3.14*r;//Circumference of a circle is 2*pi*r.

printf("The Circumference of the Circle with the given radius is: %lf",circum);//printing Circumference
}
else//If r is NOT less that 10....i.e. r is greater than 10
{
area = 3.14*r*r;//Area of a circle is pi*r*r.

printf("The Area of the Circle with the given radius is: %lf",area);//printing The area
}
getch();

}
16 changes: 16 additions & 0 deletions C/program-63/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include<stdio.h>
void main()
{
int n1,n2,n3,n4,n5;
float t;

printf("Enter Five Numbers:");
scanf("%d %d %d %d %d",&n1,&n2,&n3,&n4,&n5);

t=(n1+n2+n3+n4+n5)/5;

printf("The Average of %d,%d,%d,%d,%d is %f",n1,n2,n3,n4,n5,t);

getch();

}
7 changes: 0 additions & 7 deletions Python/Program-3/README.md

This file was deleted.

24 changes: 24 additions & 0 deletions Python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Python-basicprograms
## This repo contains basics programs in Python programming language.
| Program No.| Question |
| ------- | ------ |
| Program-01 | Program to print Hello World. |
| Program-02 | Program to find the factorial of a number. |
| Program-03 | Program to find if the string is Palindrom or not. |
| Program-04 | Program to find sum of two numbers. |
| Program-05 | Program to print a pattern. |
| Program-06 | Program to print a pattern. |
| Program-07 | Program to print a pattern. |
| Program-08 | Program to print a pattern. |
| Program-09 | Program to check if he number is armstrong or not. |
| Program-10 | Program to shuffle a deck of cards. |
| Program-11 | Program to print fibonacci series. |
| Program-12 | Program to check if a number is prime or not. |
| Program-13 | Program to find a number in an array using binary search. |
| Program-14 | Program to find simple interest for given principal amount, time and rate of interest. |
| Program-15 | Program to sort the array and give the time to sort the array. |
| Program-16 | Program to print a right angled triangle. |




11 changes: 11 additions & 0 deletions Python/program-10/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Python program to shuffle a deck of card

import itertools, random

deck = list(itertools.product(range(1,14),['Spade','Heart','Diamond','Club']))

random.shuffle(deck)

print("woohh here you got:")
for i in range(5):
print(deck[i][0], "of", deck[i][1])
21 changes: 21 additions & 0 deletions Python/program-11/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#fibonacci series
nterms = int(input("How many terms? "))

# first two terms
n1, n2 = 0, 1
count = 0

if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
else:
print("Fibonacci sequence:")
while count < nterms:
print(n1)
nth = n1 + n2
# update values
n1 = n2
n2 = nth
count += 1
22 changes: 22 additions & 0 deletions Python/program-12/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Program to check if a number is prime or not

num = 407

# To take input from the user
#num = int(input("Enter a number: "))

# prime numbers are greater than 1
if num > 1:
# check for factors
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
print(i,"times",num//i,"is",num)
break
else:
print(num,"is a prime number")

# if input number is less than
# or equal to 1, it is not prime
else:
print(num,"is not a prime number")
36 changes: 36 additions & 0 deletions Python/program-13/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Returns index of x in arr if present, else -1
def binary_search(arr, low, high, x):

# Check base case
if high >= low:

mid = (high + low) // 2

# If element is present at the middle itself
if arr[mid] == x:
return mid

# If element is smaller than mid, then it can only
# be present in left subarray
elif arr[mid] > x:
return binary_search(arr, low, mid - 1, x)

# Else the element can only be present in right subarray
else:
return binary_search(arr, mid + 1, high, x)

else:
# Element is not present in the array
return -1

# Test array
arr = [ 2, 3, 4, 10, 40 ]
x = 10

# Function call
result = binary_search(arr, 0, len(arr)-1, x)

if result != -1:
print("Element is present at index", str(result))
else:
print("Element is not present in array")
1 change: 1 addition & 0 deletions Python/program-13/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python program for binary search
16 changes: 16 additions & 0 deletions Python/program-14/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Python3 program to find simple interest
# for given principal amount, time and
# rate of interest.

def simple_interest(p,t,r):
print('The principal is', p)
print('The time period is', t)
print('The rate of interest is',r)

si = (p * t * r)/100

print('The Simple Interest is', si)
return si

# Driver code
simple_interest(8, 6, 8)
File renamed without changes.
6 changes: 3 additions & 3 deletions Python/program-4/triangle.py → Python/program-16/program.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
for i in range(5):
for j in range(i):
print('*', end=' ')
for i in range(5):
for j in range(i):
print('*', end=' ')
print()
15 changes: 14 additions & 1 deletion Python/program-2/program.py
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
print("Hello, World!")
fact=int(input("input any number"))
# input any number
factorial = 1
#predefined factorial of 0
if fact < 0:
print("factorial is not possible")
elif fact == 0:
print("factorial of "+str(fact) +" is "+str(factorial))
else:
fact1=fact
while(fact>2):
fact-=1
fact1=fact1*(fact)
print("factorial is "+ str(fact1))
2 changes: 0 additions & 2 deletions Python/program-4/README.md

This file was deleted.

18 changes: 9 additions & 9 deletions Python/program-4/Program 4.py → Python/program-4/program.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Store input numbers
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
# Add two numbers
sum = float(num1) + float(num2)
# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
# Store input numbers
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')

# Add two numbers
sum = float(num1) + float(num2)

# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
10 changes: 10 additions & 0 deletions Python/program-5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Program 5

This program gives the following pattern:

1
1 2 1 2
1 2 3 1 2 3
1 2 3 4 1 2 3 4
1 2 3 4 5 1 2 3 4 5

10 changes: 10 additions & 0 deletions Python/program-5/pragram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
for i in range(1,6):
for j in range(1,6-i):
print(" ",end=" ")
for k in range(1,i+1):
print(k,end=" ")
if i>1:
for l in range(1,i+1):
print(l,end=" ")
print()

10 changes: 10 additions & 0 deletions Python/program-6/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Program 6

The code gives the following pattern :

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

4 changes: 4 additions & 0 deletions Python/program-6/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
for i in range(1,6):
for j in range(1,i+1):
print(i,end=' ')
print()
8 changes: 8 additions & 0 deletions Python/program-7/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pattern
for i in range(1,6):
for j in range (1,6-i):
print(" ",end=" ")
for k in range(1,i+1):
print(k,end=" ")
print()

6 changes: 6 additions & 0 deletions Python/program-7/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Program to print the following pattern
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
6 changes: 6 additions & 0 deletions Python/program-8/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
c=0
for i in range(0,4):
for j in range(i+1):
print(c,end=" ")
c=c+1
print()
5 changes: 5 additions & 0 deletions Python/program-8/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
program to print the given pattern
0
1 2
3 4 5
6 7 8 9
22 changes: 22 additions & 0 deletions Python/program-9/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#Python Program to Find Armstrong Number in an Interval


lower = 100
upper = 2000

for num in range(lower, upper + 1):

# order of number
order = len(str(num))

# initialize sum
sum = 0

temp = num
while temp > 0:
digit = temp % 10
sum += digit ** order
temp //= 10

if num == sum:
print(num)
Binary file added gif/giphy.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Basic programs
<h1 align="center"> Basic Program</h1>
<!-- <h2 align="center"> Bot built for Instagram using Python and Selenium. </h2>
<h3 align="center">
This is an Instagram bot that can automate and perform some tasks; makes your task easier. The Bot can show the list of un-followers from you Instagram or it can show your fans and also it can cancel all the pending follow requests which you have already sent before or it can also unfollow those who don't follow you back.
</h3> -->
<div align="center">
<img src="./gif/giphy.gif" width="300x" >
</div>

## This repo contains basics programs in all languages.
## Contribution
If you want to contribute to this repo then [click here](https://github.com/swaaz/basicprograms/blob/swaaz/.github/ISSUE_TEMPLATE/contribution.md)