answersLogoWhite

0


Best Answer

#include<iostream>

#include<iomanip>

#include<time.h>

template<typename T>

size_t find(T& data, T a[], size_t size)

{

size_t index=0;

do {

if(a[index]==data)

break;

} while(++index<size);

return(index);

}

template<typename T>

void print(T a[], size_t size)

{

using std::cout;

using std::endl;

using std::setw;

size_t index=0;

do{

if(index&&index%20==0)

cout<<endl;

cout<<setw(3)<<a[index];

}while(++index<size);

cout<<endl;

}

int main()

{

srand((unsigned)time(NULL));

const size_t size=100;

unsigned int a[size];

size_t index=0;

do{

unsigned int data=rand()%100;

do{

data=rand()%100;

} while(find(data,a,index)<index);

a[index]=data;

} while(++index<size);

print(a,size);

}

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program in C plus plus to store 100 element within array and find the particular element if exist?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a JSP program which displays webpage containing arrival of new items within a particular month in the different branches of a retail company?

vbcvbvbvcbc vbcvbvbvcbc


Write a c program on reverse the diagonal element of matrix?

mano ni anda yarrr


What is the functional of a bus?

The bits of address bus inform the memory(Ram) which particular element is to be read or write in memory.


Write c program to find median?

If you are using an array : sort using qsort() then take middle element.


Write a problom that can be solved by making a table and using a pattern Then solve the problem?

You can draw a flowchart of solving a particular problem and then write a program to solve that problem.


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


Is it more efficient to store the data in a matrix then write it to the file at the end of the program or to write each element to the file as the program runs?

It shouldn't make significant difference, only if the matrix is huge -- in that case you shouldn't store it in memory.


A program written in a high-level programming language is called?

the program written in high level language is called "source program"


How do you write a java program to find the transpose of the matrix for the given elements?

You basically write a nested for loop (one for within another one), to copy the elements of the matrix to a new matrix.


Write a program to find out the address of an element in an array?

== Java does not allow reference to memory locations. == In C: for (i=0; i&lt;n; ++i) printf ("a[%d] is at %p\n", i, &amp;a[i]);


Write to him.He will answer you?

Write to whom in particular?


Is it possible to perform a calculation within a database?

Yes you can. You can create queries that do calculations. You can write code for programs to do calculations in a database. Doing calculations is a significant element of what you do with a database, so yes you can do them within a database.