Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 24 additions & 15 deletions C/program-21/program.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
#include<stdio.h>
/*
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 <stdio.h>
#include <stdlib.h>

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;
}
int count=0,n=0;
while(n!=-1)
{
scanf("%d",&n);
count++;

}
printf("%d",count-1);
return 0;
}
14 changes: 14 additions & 0 deletions C/program-33/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Arithematic operation using pointers */
#include <stdio.h>
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));

}

37 changes: 37 additions & 0 deletions C/program-34/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*In this assignment, you will be given an NxN matrix. You have 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 <stdio.h>
#include <stdlib.h>

int main()
{
int a[10][10],n,i,j,flag=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{scanf("%d",&a[i][j]);
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(!(i==j) &&(i>j || j>i) ) flag=1;
}
}
if(!(flag))printf("no\n");
else printf("yes");
return 0;
}
25 changes: 25 additions & 0 deletions C/program-35/program.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <stdlib.h>

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;
}
2 changes: 1 addition & 1 deletion Python/program-2/program.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
print("Hello, World!")
print("Hello, World!")