- #include <stdio.h>
- #include <conio.h>
- void main()
- {
- int array[100], search, i, n, count = 0;
- printf("Enter the number of elements in array\n");
- scanf("%d", &n);
- printf("Enter %d numbers\n", n);
- for ( i = 0 ; i < n ; i++ )
- {
- scanf("%d", &array[i]);
- }
- printf("Enter the number to search\n");
- scanf("%d", &search);
- for (i = 0; i < n; i++) {
- if (array[i] == search) {
- printf("%d is present at location %d.\n", search, i+1);
- count++;
- }
- }
- if (count == 0)
- printf("%d is not present in array.\n", search);
- else
- printf("%d is present %d times in array.\n", search, count);
- getch();
- }
Tuesday, 14 February 2017
Linear Search Program In C For Multiple Occurrences
Subscribe to:
Post Comments (Atom)
Upload valid file in C#
protected bool CheckFileExtandLength(HttpPostedFile HtmlDocFile) { try { Dictionary<string, byte[]...
-
Setting Header Programatically You can also set the cache headers programmatically. This can be useful for generated content and allows m...
-
CREATE TABLE dbo.M_Bank ( ID INT IDENTITY NOT NULL, MB_NAME NVARCHAR (50), MB_SNAME NVARCHAR (20), MB_ADDUSER ...
-
SELECT distinct(volume_mount_point), total_bytes/1048576 as Size_in_MB, total_bytes/1048576/1024 as Size_in_GB, available_bytes/1048576 ...
No comments:
Post a Comment