Skip to content

Commit 7f1c660

Browse files
authored
Add files via upload
1 parent ec3344a commit 7f1c660

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

Arrays/integer.c

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/* Title : Enter the data elments before that mention the their total count . .
2+
After entering the data you first missed positive integer missed will
3+
be displayed .
4+
Code is done in C language .
5+
*/
6+
#include<stdio.h>
7+
#include<stdlib.h>
8+
int main()
9+
{
10+
int n ,j=0, i,k=1 , val;
11+
int opt=1;
12+
printf("\n Enter the total number of elements : \n");
13+
scanf("%d",&n);
14+
if(n<=0)
15+
{
16+
printf("\n Invalid Input , Try again later !! \n");
17+
exit(0);
18+
}
19+
int a[n];
20+
printf("\n Enter the elements : \n");
21+
for(i=0;i<n;i++)
22+
{ scanf("%d",&a[i]); }
23+
24+
for(i=0;i<n;i++)
25+
{ for(j=0;j<n-1;j++)
26+
if(a[j]>a[j+1])
27+
{ val=a[j];
28+
a[j]=a[j+1];
29+
a[j+1]=val; }
30+
}
31+
printf("\n Sorted array : \n");
32+
for(i=0;i<n;i++)
33+
{
34+
printf(" %d ", a[i]);
35+
}
36+
printf("\n \n");
37+
printf("\n Postive element missed from the data is ");
38+
if(a[n-1]<=0)
39+
{
40+
printf("\n1\n");
41+
42+
43+
}
44+
else {
45+
46+
for(i=0;i<n;i++)
47+
{
48+
if(a[i]>0)
49+
{
50+
for(j=0+i, k=1;j<=n && k<=n+1;k++,j++)
51+
{
52+
if(a[j]==k)
53+
{
54+
continue ;
55+
}
56+
else
57+
{
58+
59+
printf(" %d " ,k);
60+
exit(0);
61+
62+
}
63+
64+
65+
66+
}
67+
}
68+
}
69+
}
70+
71+
}
72+
73+
74+
/*
75+
76+
Enter the total number of elements :
77+
7
78+
79+
Enter the elements :
80+
0
81+
-1
82+
1
83+
-2
84+
-3
85+
-4
86+
-5
87+
88+
Sorted array :
89+
-5 -4 -3 -2 -1 0 1
90+
91+
92+
Postive element missed from the data is 2
93+
94+
*/

0 commit comments

Comments
 (0)