diff --git a/C++/Program-4/README.md b/C++/Program-4/README.md new file mode 100644 index 00000000..e7df3251 --- /dev/null +++ b/C++/Program-4/README.md @@ -0,0 +1,2 @@ +Program -4 +Program to find the reverse of a string diff --git a/C++/Program-4/factorial.cpp b/C++/Program-4/factorial.cpp new file mode 100644 index 00000000..27796e1e --- /dev/null +++ b/C++/Program-4/factorial.cpp @@ -0,0 +1,29 @@ +#include +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 +using namespace std; + +int main() { + string s; + cout<<"Enter the string"<>s; + int n=s.length(); + for (int i = 0; i < n / 2; i++) + swap(s[i], s[n - i - 1]); + cout< +using namespace std; + +int main() { + cout<<"enter the number\n"; + int n; + cin>>n; + int temp, rem, sum = 0; + temp = n; + while(temp>0) + { + rem = temp%10; + temp = temp/10; + sum+=rem; + } + cout<<"\nThe sum is "< +#include +#include + +int main() +{ + /* Length of the password */ + int length; + int num; + int temp; + printf("Enter the length of the password: "); + scanf("%d", &length); + printf("\nEnter the number of passwords you want: "); + scanf("%d", &num); + /* Seed number for rand() */ + srand((unsigned int) time(0) + getpid()); + + while(num--) + { + temp = length; + printf("\n"); + while(temp--) { + putchar(rand() % 56 + 65); + srand(rand()); + } + + temp = length; + } + + printf("\n"); + + return EXIT_SUCCESS; +} diff --git a/C/program-53/Readme.md b/C/program-53/Readme.md new file mode 100644 index 00000000..8809d9d9 --- /dev/null +++ b/C/program-53/Readme.md @@ -0,0 +1 @@ +Program to find the position of an element in an array \ No newline at end of file diff --git a/C/program-55/read.md b/C/program-55/readme.md similarity index 100% rename from C/program-55/read.md rename to C/program-55/readme.md diff --git a/C/program-57/program.c b/C/program-57/program.c new file mode 100644 index 00000000..cac40c26 --- /dev/null +++ b/C/program-57/program.c @@ -0,0 +1,26 @@ +#include + +int main () { + float score; + printf("Enter your total score (0-100): "); + scanf("%f",&score); + if(score < 0 || score > 100) { + printf("Enter score 0 - 100 \n"); + } else if(score >= 80) { + printf("Score = %.2f , You Grade : A\n",score); + } else if(score >= 75) { + printf("Score = %.2f , You Grade : B+\n",score); + } else if(score >= 70) { + printf("Score = %.2f , You Grade : B\n",score); + } else if(score >= 65) { + printf("Score = %.2f , You Grade : C+\n",score); + } else if(score >= 60) { + printf("Score = %.2f , You Grade : C\n",score); + } else if(score >= 55) { + printf("Score = %.2f , You Grade : D+\n",score); + } else if(score >= 50) { + printf("Score = %.2f , You Grade : D\n",score); + } else { + printf("Score = %.2f , You Grade : F\n",score); + } +} \ No newline at end of file diff --git a/C/program-57/readme.md b/C/program-57/readme.md new file mode 100644 index 00000000..6d1d4966 --- /dev/null +++ b/C/program-57/readme.md @@ -0,0 +1,4 @@ +Program 57 + + +Write a program in C to calculate the grade diff --git a/C/program-58/Program.c b/C/program-58/Program.c new file mode 100644 index 00000000..709d4d23 --- /dev/null +++ b/C/program-58/Program.c @@ -0,0 +1,24 @@ + #include +void main() + +{ + //float n[10]; + int i,sum,a,b,x; + printf("enter the size of elements\n"); + scanf("%d", &x); + float n[x]; + printf("enter the values\n"); + for (i=0;i +#include + +typedef struct student +{ + + char name[25]; + char usn[15]; + float cgpa; +} S; +S s[70]; + + +void search(char name[],int n) +{ + + int i,j; + // printf("%s\n",name); + for(i=0;i +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(); + +} diff --git a/C/program-63/program.c b/C/program-63/program.c new file mode 100644 index 00000000..b89e54f9 --- /dev/null +++ b/C/program-63/program.c @@ -0,0 +1,16 @@ +#include +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(); + +} diff --git a/Java/program-2/README.md b/Java/program-2/README.md new file mode 100644 index 00000000..7ed914ac --- /dev/null +++ b/Java/program-2/README.md @@ -0,0 +1,9 @@ +Program 2 + +Given a String,check if it is a palindrome or not. + +Variable description +s= Input String +start= Starting index of String s +end= Last index of String s +flag= Variable to mark if the String is not a Palindrome \ No newline at end of file diff --git a/Java/program-2/program.java b/Java/program-2/program.java new file mode 100644 index 00000000..a9d9adda --- /dev/null +++ b/Java/program-2/program.java @@ -0,0 +1,26 @@ +import java.io.*; +import java.util.*; +class prg{ + public static void main(String args[]) + { + Scanner sc=new Scanner(System.in); + String s=sc.next(); + int start=0; + int end=s.length()-1; + int flag=0; + while(start + +MATHEMATICAL OPERATIONS OF TWO NUMBERS + + +
+ENTER NUMBER1:
+ENTER NUMBER2:
+ + + + +Reset: +Result: +
+ + + diff --git a/Javascript/program-5/read.md b/Javascript/program-5/read.md new file mode 100644 index 00000000..24771b46 --- /dev/null +++ b/Javascript/program-5/read.md @@ -0,0 +1,4 @@ +# Program-5 +## This is a javascript program for mathematical operations + + diff --git a/Javascript/program-6/program-6.html b/Javascript/program-6/program-6.html new file mode 100644 index 00000000..55d8806f --- /dev/null +++ b/Javascript/program-6/program-6.html @@ -0,0 +1,17 @@ + + + CHARACTER PROCESSING METHODS + + + + + diff --git a/Javascript/program-6/read.md b/Javascript/program-6/read.md new file mode 100644 index 00000000..61cc055a --- /dev/null +++ b/Javascript/program-6/read.md @@ -0,0 +1,3 @@ +# Program-4 +## This is a javascript program for character processing + diff --git a/Python/program-10/armstrong.py b/Python/program-10/armstrong.py new file mode 100644 index 00000000..7e0967c6 --- /dev/null +++ b/Python/program-10/armstrong.py @@ -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) diff --git a/Python/program-11/shufflecards.py b/Python/program-11/shufflecards.py new file mode 100644 index 00000000..df6429bd --- /dev/null +++ b/Python/program-11/shufflecards.py @@ -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]) diff --git a/Python/program-4/Program 4.py b/Python/program-4/Program 4.py new file mode 100644 index 00000000..77c405f9 --- /dev/null +++ b/Python/program-4/Program 4.py @@ -0,0 +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)) diff --git a/Python/program-4/README.md b/Python/program-4/README.md new file mode 100644 index 00000000..7137f722 --- /dev/null +++ b/Python/program-4/README.md @@ -0,0 +1,2 @@ +# triangle.py +# Draws a triangle \ No newline at end of file diff --git a/Python/program-4/triangle.py b/Python/program-4/triangle.py new file mode 100644 index 00000000..da4902eb --- /dev/null +++ b/Python/program-4/triangle.py @@ -0,0 +1,4 @@ +for i in range(5): + for j in range(i): + print('*', end=' ') + print() \ No newline at end of file diff --git a/Python/program-5/README.md b/Python/program-5/README.md new file mode 100644 index 00000000..669d2d67 --- /dev/null +++ b/Python/program-5/README.md @@ -0,0 +1,7 @@ +Program 5 + +Write a program to find a factorial of a number. + +Variable description-- +fact= Holds the input number + diff --git a/Python/program-5/factorial.py b/Python/program-5/factorial.py new file mode 100644 index 00000000..9db2639b --- /dev/null +++ b/Python/program-5/factorial.py @@ -0,0 +1,14 @@ +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)) \ No newline at end of file diff --git a/Python/program-5/pattern.py b/Python/program-5/pattern.py new file mode 100644 index 00000000..e067d825 --- /dev/null +++ b/Python/program-5/pattern.py @@ -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() + \ No newline at end of file diff --git a/Python/program-6/README.md b/Python/program-6/README.md new file mode 100644 index 00000000..8d8c46c6 --- /dev/null +++ b/Python/program-6/README.md @@ -0,0 +1,7 @@ +Program 6 + +Write a program to check whether a number is prime or not + +Variable description-- +n= holds input value + diff --git a/Python/program-6/pattern.py b/Python/program-6/pattern.py new file mode 100644 index 00000000..456583e0 --- /dev/null +++ b/Python/program-6/pattern.py @@ -0,0 +1,4 @@ +for i in range(1,6): + for j in range(1,i+1): + print(i,end=' ') + print() diff --git a/Python/program-6/program.py b/Python/program-6/program.py new file mode 100644 index 00000000..8b70a1d6 --- /dev/null +++ b/Python/program-6/program.py @@ -0,0 +1,14 @@ +n=int(input("enter any number")) +# n is the number to check whether it is prime or not +if n>1: + # loop from 2 to n/2 + for i in range(2,int(n/2)): + + if(n%i)==0: + #if n is completly divisible by i then it is not a prime number + print("n is not prime") + break + else: + print("n is prime") +else: + print("not prime") diff --git a/Python/program-7/pattern3.py b/Python/program-7/pattern3.py new file mode 100644 index 00000000..601bfdbb --- /dev/null +++ b/Python/program-7/pattern3.py @@ -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() + \ No newline at end of file diff --git a/Python/program-7/readme.md b/Python/program-7/readme.md new file mode 100644 index 00000000..4f87ac17 --- /dev/null +++ b/Python/program-7/readme.md @@ -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 \ No newline at end of file diff --git a/Python/program-8/pattern4.py b/Python/program-8/pattern4.py new file mode 100644 index 00000000..683d48d8 --- /dev/null +++ b/Python/program-8/pattern4.py @@ -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() \ No newline at end of file diff --git a/Python/program-8/readme.md b/Python/program-8/readme.md new file mode 100644 index 00000000..a3b103b0 --- /dev/null +++ b/Python/program-8/readme.md @@ -0,0 +1,5 @@ +program to print the given pattern +0 +1 2 +3 4 5 +6 7 8 9 \ No newline at end of file diff --git a/readme.md b/readme.md index b41b556d..25413caa 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ # Basic programs -## This repo contains basics programs in c programming language and python. +## 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)