1. Write a program that performs the following. The user
inputs a number and then enters a series of numbers
from 1 to that number. Your program should determine
which number (or numbers) is missing or duplicated in
the series, if any. For example, if the user entered
5 as the initial number and then entered the
following sequences, the results should be as shown.

Input Sequence Output
---------------------- ---------------
1 2 3 4 5 Nothing bad

However, if 7 were the high number, the user
would see the results on the right for the following
number entries:

Input Sequence Output
---------------------- ---------------
1 3 2 4 5 Missing 6
Missing 7

And if 10 were the high number and the user
entered the numbers shown on the left, note the list
of missing and duplicate numbers:

Input Sequence Output
---------------------- ---------------
1 2 4 7 4 4 5 10 8 2 6 Duplicate 2 ( 2 times)
Missing 3
Duplicate 4 ( 3 times )
Missing 9



1. Write a program that performs the following. The user inputs a number and then enters a ser..

Answer / md. mohaiminul islam

#include <stdio.h>
#include <conio.h>
void main(void)
{
int a[100];
int s,c;
int b=0;
clrscr ();
printf("type lage number of your serise:\n");
scanf("%d",&c);
printf("Plz type how many numbers you want to check:\n");
scanf("%d",&s);
printf("Type the numbers you want to check\n");
for (int i=0;i<s;i++)
scanf("%d",&a[i]);
for (int x=1;x<=c;x++)
{
for (int y=0;y<s;y++)
if (a[y]==x)
b++;
if (b>=2)
printf("Duplicate %d :(%d) time's\n",x,b);
if (b==0)
printf("%d is missing.\n",x);
b=0;
};
getch ();
}

Is This Answer Correct ?    16 Yes 12 No

Post New Answer

More C++ Code Interview Questions

Min-Max Write an algorithm that finds both the smallest and largest numbers in a list of n numbers and calculate its complexity T(n).

1 Answers   Infosys, Qatar University,


Complexity T(n) What is the time complexity T(n) of the following portions of code? For simplicity, you may assume that n is a power of 2. That is, n = 2k for some positive integer k. a) ? for (i = 1; i <= n; i++) { j = n; cout << i << ? ? j << ? ? << endl; } b) ? for (i = 0; i <= n; i += 2) { j = n; cout << i << ? ? j << ? ? << endl; } c) ? for (i = n; i >= 1; i = i/2) { j = n; cout << i << ? ? j << ? ? << endl; } d) for (i = 1; i <= n; i++) { j = n; while (j >= 0) { cout << i << ? ? j << ? ? << endl; j = j - 2; } }

0 Answers   Qatar University,


Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)

3 Answers   Nagarro,


Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?

0 Answers   Wipro,


How to swap two ASCII numbers?

0 Answers  






#include<stdio.h> #include<conio.h> void main() { char str[10]; int,a,x,sw=0; clrscr(); printf("Enter a string:"); gets(str); for(x=0;x<=a;a++); for(x=0;x<=a;x++) { if(str[x]==str[a-1-x]) { sw=1; } else sw=0; } if(sw==10 printf("The entered string is palindrome:"); else printf("The entered string is not a palindrome:); } getch(); } wht would be the explanation with this written code???

2 Answers  


Find the maximum product of three numbers in an array? Eg. 9,5,1,2,3 Max product= 9*5*3= 135 The array can hav negative numbers also..

7 Answers   CTS,


How to Split Strings with Regex in Managed C++ Applications?

0 Answers   Microsoft,


using friend function find the maximum number from given two numbers from two different classes.write all necessary functions and constructor for the classes.

1 Answers   TCS,


Write a program to enter 10 number of integer entries into an array n and then odds up all the odd entries. the program then displays the result. plssss answer assss fast asss u can...

1 Answers  


create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file

0 Answers   HCL,


output for printf("printf");

0 Answers  


Categories