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 |
output for printf("printf");
hello friends, given an expression we have to remove the unwanted brackets in that expression. Eg : (a+b) ---> a+b (a+b)*(c)-----> (a+b)*c. Please mail me if you know the logic. My mail id is : saravana6m@gmail.com. Thank you in advance :-)
1 Answers GrapeCity, Microsoft,
i really need help about this.. write a program to display the set of odd and even numbers separately. find the highest and lowest value of the given numbers.
Write a program using one dimensional array that searches a number and display the number of times it occurs on the list of 12 input values. Sample input/output dialogue: Enter 12 values: 13 15 20 13 30 35 40 16 18 20 18 20 Enter number to search: 20 Occurences: 3
Write a (n) algorithm that sorts n distinct integers, ranging in size between 1 and kn inclusive, where k is a constant positive integer. (Hint: Use a kn-element array.)
write a program using virtual function to find the transposing of a square matrix?
write a function that allocates memory for a single data type passed as a parameter.the function uses the new operator and return a pointer to the allocated memory.the function must catch and handle any exception during allocation
Code for Method of Handling Factorials of Any Size?
write a function – oriented program that calculates the sum of the squares from 1 to n. thus, if the input is 3, the output is 14
Write a program using one dimensional array that accept five values from the keyboard. Then it should also accept a number to search. This number is to be searched if it among the five input values. If it is found, display the message “Search number is found!” otherwise, display “Search is lost”. Example: Enter 5 numbers: 10 15 20 7 8 Enter number to search: 7 Search number is found!
2 Answers College School Exams Tests,
write a proram using exceptional handling create a error & display the message "THERE IS AN ERROR?... PLEASE RECTIFY"?
Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.