Docsity

data structure lab for function, Exercises of Data Structures and Algorithms

Partial preview of the text

Download data structure lab for function and more Exercises Data Structures and Algorithms in PDF only on Docsity!

Lab#

Task#1:

#include using namespace std; int main() { int millisec=0; int status=0; int n;

cout<<"enter the prime number"; cin>>n; for(int i=2;i<n;i++) { if(n%i==0) {

status=0; } millisec++; }

if(status) { cout<<"is prime # "<<"and"<<endl; cout<<"time ="<<millisec; }

else{

cout<<"not a prime # "<<"and"<<endl; cout<<"time ="<<millisec; } return 0; system("pause"); } v

Task#2:

#include

return 0; system("pause"); }

Co

cout<<"is prime # "<<"and"<<endl; cout<<"time ="<<millisec; } else{

cout<<"not a prime # "<<"and"<<endl; cout<<"time ="<<millisec; } return 0; system("pause");