diff --git a/README.md b/C/README.md similarity index 77% rename from README.md rename to C/README.md index c01ca966..d837d3c1 100644 --- a/README.md +++ b/C/README.md @@ -34,3 +34,7 @@ | Program-30 | Program to print the pattern | | Program-31 | Program to take the details of student and print the details of students using array and to add details of new students into the existing array | | Program-32 | Program to take the details of student and print the details | +| Program-33 | Program on Arithematic operation using pointers | +| Program-34 | Program to determine whether the matrix is a triangular matrix. First, you will be given N, which is the size of the matrix. Then you will be given N rows of integers, where each row consists of N integers separated by spaces. If the input matrix is triangular, then print yes. Otherwise, print no. | +| Program-35 | Program where you are given a sequence of non-negative integers terminated by -1. You have to output 1 if there are atleast 2 distinct elements in the sequence and 0 if the sequence consists of only 1 integer. Note that -1 is not part of the sequence. The sequence is not necessarily sorted. | + diff --git a/program-1/a.out b/C/program-1/a.out similarity index 100% rename from program-1/a.out rename to C/program-1/a.out diff --git a/program-1/program.c b/C/program-1/program.c similarity index 100% rename from program-1/program.c rename to C/program-1/program.c diff --git a/program-1/read.md b/C/program-1/read.md similarity index 100% rename from program-1/read.md rename to C/program-1/read.md diff --git a/program-10/program.c b/C/program-10/program.c similarity index 100% rename from program-10/program.c rename to C/program-10/program.c diff --git a/program-11/program.c b/C/program-11/program.c similarity index 100% rename from program-11/program.c rename to C/program-11/program.c diff --git a/program-12/program.c b/C/program-12/program.c similarity index 100% rename from program-12/program.c rename to C/program-12/program.c diff --git a/program-13/program.c b/C/program-13/program.c similarity index 100% rename from program-13/program.c rename to C/program-13/program.c diff --git a/program-14/program.c b/C/program-14/program.c similarity index 100% rename from program-14/program.c rename to C/program-14/program.c diff --git a/program-15/a.out b/C/program-15/a.out similarity index 100% rename from program-15/a.out rename to C/program-15/a.out diff --git a/program-15/program.c b/C/program-15/program.c similarity index 100% rename from program-15/program.c rename to C/program-15/program.c diff --git a/program-15/readme.md b/C/program-15/readme.md similarity index 100% rename from program-15/readme.md rename to C/program-15/readme.md diff --git a/program-16/.vscode/launch.json b/C/program-16/.vscode/launch.json similarity index 100% rename from program-16/.vscode/launch.json rename to C/program-16/.vscode/launch.json diff --git a/program-16/a.out b/C/program-16/a.out similarity index 100% rename from program-16/a.out rename to C/program-16/a.out diff --git a/program-16/program.c b/C/program-16/program.c similarity index 100% rename from program-16/program.c rename to C/program-16/program.c diff --git a/program-16/readme.md b/C/program-16/readme.md similarity index 100% rename from program-16/readme.md rename to C/program-16/readme.md diff --git a/program-17/a.out b/C/program-17/a.out similarity index 100% rename from program-17/a.out rename to C/program-17/a.out diff --git a/program-17/program.c b/C/program-17/program.c similarity index 100% rename from program-17/program.c rename to C/program-17/program.c diff --git a/program-18/program.c b/C/program-18/program.c similarity index 100% rename from program-18/program.c rename to C/program-18/program.c diff --git a/program-19/a.out b/C/program-19/a.out similarity index 100% rename from program-19/a.out rename to C/program-19/a.out diff --git a/program-19/program.c b/C/program-19/program.c similarity index 100% rename from program-19/program.c rename to C/program-19/program.c diff --git a/program-2/program.c b/C/program-2/program.c similarity index 100% rename from program-2/program.c rename to C/program-2/program.c diff --git a/program-2/read.md b/C/program-2/read.md similarity index 100% rename from program-2/read.md rename to C/program-2/read.md diff --git a/program-20/a.out b/C/program-20/a.out similarity index 100% rename from program-20/a.out rename to C/program-20/a.out diff --git a/program-20/program.c b/C/program-20/program.c similarity index 100% rename from program-20/program.c rename to C/program-20/program.c diff --git a/program-21/a.out b/C/program-21/a.out similarity index 100% rename from program-21/a.out rename to C/program-21/a.out diff --git a/C/program-21/program.c b/C/program-21/program.c new file mode 100644 index 00000000..3fa728fa --- /dev/null +++ b/C/program-21/program.c @@ -0,0 +1,26 @@ +/* +You are given a sorted (either in the increasing or in the decreasing order) sequence of numbers, ending with a -1. You can assume that are at least two numbers before the ending -1. + +Let us call the sequence x0 x1 ... xn -1. + +You have to output the number of distinct elements in the sorted sequence. + +Kindly do not use arrays in the code. +*/ + + +#include +#include + +int main() +{ + int count=0,n=0; + while(n!=-1) + { + scanf("%d",&n); + count++; + + } +printf("%d",count-1); + return 0; +} diff --git a/program-22/a.out b/C/program-22/a.out similarity index 100% rename from program-22/a.out rename to C/program-22/a.out diff --git a/program-22/program.c b/C/program-22/program.c similarity index 100% rename from program-22/program.c rename to C/program-22/program.c diff --git a/program-23/a.out b/C/program-23/a.out similarity index 100% rename from program-23/a.out rename to C/program-23/a.out diff --git a/program-23/program.c b/C/program-23/program.c similarity index 100% rename from program-23/program.c rename to C/program-23/program.c diff --git a/program-24/a.out b/C/program-24/a.out similarity index 100% rename from program-24/a.out rename to C/program-24/a.out diff --git a/program-24/program.c b/C/program-24/program.c similarity index 100% rename from program-24/program.c rename to C/program-24/program.c diff --git a/program-25/a.out b/C/program-25/a.out similarity index 100% rename from program-25/a.out rename to C/program-25/a.out diff --git a/program-25/program.c b/C/program-25/program.c similarity index 100% rename from program-25/program.c rename to C/program-25/program.c diff --git a/program-26/a.out b/C/program-26/a.out similarity index 100% rename from program-26/a.out rename to C/program-26/a.out diff --git a/program-26/program.c b/C/program-26/program.c similarity index 100% rename from program-26/program.c rename to C/program-26/program.c diff --git a/program-27/a.out b/C/program-27/a.out similarity index 100% rename from program-27/a.out rename to C/program-27/a.out diff --git a/program-27/program.c b/C/program-27/program.c similarity index 100% rename from program-27/program.c rename to C/program-27/program.c diff --git a/program-28/a.out b/C/program-28/a.out similarity index 100% rename from program-28/a.out rename to C/program-28/a.out diff --git a/program-28/program.c b/C/program-28/program.c similarity index 100% rename from program-28/program.c rename to C/program-28/program.c diff --git a/program-29/a.out b/C/program-29/a.out similarity index 100% rename from program-29/a.out rename to C/program-29/a.out diff --git a/program-29/program.c b/C/program-29/program.c similarity index 100% rename from program-29/program.c rename to C/program-29/program.c diff --git a/program-3/program.c b/C/program-3/program.c similarity index 100% rename from program-3/program.c rename to C/program-3/program.c diff --git a/program-30/a.out b/C/program-30/a.out similarity index 100% rename from program-30/a.out rename to C/program-30/a.out diff --git a/program-30/program.c b/C/program-30/program.c similarity index 100% rename from program-30/program.c rename to C/program-30/program.c diff --git a/program-31/a.out b/C/program-31/a.out similarity index 100% rename from program-31/a.out rename to C/program-31/a.out diff --git a/program-31/program.c b/C/program-31/program.c similarity index 100% rename from program-31/program.c rename to C/program-31/program.c diff --git a/program-32/program.c b/C/program-32/program.c similarity index 100% rename from program-32/program.c rename to C/program-32/program.c diff --git a/C/program-33/program.c b/C/program-33/program.c new file mode 100644 index 00000000..80f7131f --- /dev/null +++ b/C/program-33/program.c @@ -0,0 +1,14 @@ +/* Arithematic operation using pointers */ +#include +void main() +{ +int a,b; +int *x,*y; +scanf("%d%d",&a,&b); +x=&a; +y=&b; +//s=; +printf("%d\t%d",*x+*y,abs(*x-*y)); + +} + diff --git a/C/program-34/program.c b/C/program-34/program.c new file mode 100644 index 00000000..4e0af2f0 --- /dev/null +++ b/C/program-34/program.c @@ -0,0 +1,36 @@ +/* To determine whether the matrix is a triangular matrix. +First, you will be given N, which is the size of the matrix. + +Then you will be given N rows of integers, where each row consists of +N integers separated by spaces. +If the input matrix is triangular, then print yes. Otherwise, print +no. */ + + + + + +#include +#include + +int main() +{ +int a[10][10],n,i,j,flag=0; + scanf("%d",&n); + for(i=0;ij || j>i) ) flag=1; + } + } + if(!(flag))printf("no\n"); + else printf("yes"); + return 0; +} diff --git a/C/program-35/program.c b/C/program-35/program.c new file mode 100644 index 00000000..97c5c795 --- /dev/null +++ b/C/program-35/program.c @@ -0,0 +1,25 @@ +/* You are given a sequence of non-negative integers terminated by -1. + You have to output 1 if there are atleast 2 distinct elements in the sequence and 0 if the sequence consists of only 1 integer. + Note that -1 is not part of the sequence. The sequence is not necessarily sorted. */ + + +#include +#include + +int main() +{ + int a=0,n=0,count=0; + while(n!=-1) + { + scanf("%d",&n); + if(a!=n) + { + a=n; + count++; + } + + } +if(count>=2) printf("%d",1); +else printf("%d",0); + return 0; +} diff --git a/program-4/program.c b/C/program-4/program.c similarity index 100% rename from program-4/program.c rename to C/program-4/program.c diff --git a/program-5/program.c b/C/program-5/program.c similarity index 100% rename from program-5/program.c rename to C/program-5/program.c diff --git a/program-6/program.c b/C/program-6/program.c similarity index 100% rename from program-6/program.c rename to C/program-6/program.c diff --git a/program-7/program.c b/C/program-7/program.c similarity index 100% rename from program-7/program.c rename to C/program-7/program.c diff --git a/program-8/program.c b/C/program-8/program.c similarity index 100% rename from program-8/program.c rename to C/program-8/program.c diff --git a/program-9/program.c b/C/program-9/program.c similarity index 100% rename from program-9/program.c rename to C/program-9/program.c diff --git a/Python/program-1/program.py b/Python/program-1/program.py new file mode 100644 index 00000000..4648e701 --- /dev/null +++ b/Python/program-1/program.py @@ -0,0 +1 @@ +print("Hello, World!") \ No newline at end of file diff --git a/Python/program-2/program.py b/Python/program-2/program.py new file mode 100644 index 00000000..7df869a1 --- /dev/null +++ b/Python/program-2/program.py @@ -0,0 +1 @@ +print("Hello, World!") diff --git a/program-21/program.c b/program-21/program.c deleted file mode 100644 index 0cfb05d1..00000000 --- a/program-21/program.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -int main() -{ - int a,i,count=0; - printf("enter the number\n"); - scanf("%d",&a); - for(i=2;i<=a/2;i++) - { - if(a%i==0) - { - count=1; - break; - }} -if(count) printf("not prime"); -else printf("prime"); -return 0; -} \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 00000000..39f1a208 --- /dev/null +++ b/readme.md @@ -0,0 +1,2 @@ +# Basic programs +## This repo contains basics programs in c programming language and python. \ No newline at end of file