From bd7e20748c0e6c0d3b8ff88a528ae089a0f1f432 Mon Sep 17 00:00:00 2001 From: Swasthik shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 14 Aug 2019 23:50:51 +0530 Subject: [PATCH] Create program.c --- C/program-36/program.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 C/program-36/program.c diff --git a/C/program-36/program.c b/C/program-36/program.c new file mode 100644 index 00000000..9d823305 --- /dev/null +++ b/C/program-36/program.c @@ -0,0 +1,29 @@ +/* + +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,m; + while(n!=-1) + { + scanf("%d",&n); + if(m!=n) count++; + else continue; + m=n; + + } +printf("%d",count-1); + return 0; +}