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
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 |
write a program that reads a series of strings and prints only those strings begging with letter "b"
write a program to sort 'n' elemnts using bubble sort
write a program in c++ to scramble a bmp image file using a scramble key 0x7c and an XOR logic. print out the original image, the scrambled image and the program. Note: the first 24bytes of a bmp file contain the header information of the file.
Write A C++ Program To Input A Number Between 20 To 99 And Display Its Numbername?
can you please write a program for deadlock that can detect deadlock and to prevent deadlock.
What output does this program generate as shown? Why? class A { A() { cout << "A::A()" << endl; } ~A() { cout << "A::~A()" << endl; throw "A::exception"; } }; class B { B() { cout << "B::B()" << endl; throw "B::exception"; } ~B() { cout << "B::~B()"; } }; int main(int, char**) { try { cout << "Entering try...catch block" << endl; A objectA; B objectB; cout << "Exiting try...catch block" << endl; } catch (char* ex) { cout << ex << endl; } return 0; }
Write a program using two-dimensional arrays that determines the highest and lowest of the 12 input values. Example: Enter 12 numbers: 13 15 20 13 35 40 16 18 20 18 20 14 highest: 40 lowest: 13
Write a program that print in screen a tree with its height taken from user by entering number of 4 digits and find the odd numbers then calculate the sum of odd numbers so he get the height of tree?
. Write a program using two-dimensional arrays that computes the sum of data in tows and the sum of data in columns of the 3x3 (three by three) array variable n[3][3].
Given 1 to n distinct random number of which n+1th element was duplicated. How do find the duplicate element and explain the time complexity of the algorithm.
readers and writers problem
#include<iostream.h> //main() //{ class A { friend class B; public: void read(); }; class B { public : int a,b; }; void A::read() { cout<<"welcome"; } main() { A x; B y; y.read(); } In the above program......, as B is a friend of A B can have access to all members,i cant access y.read . could you please tell me the reason and what would i code to execute this program?