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

computer science data structure

Typology: Exercises

2017/2018

Uploaded on 10/14/2018

noman
noman 🇵🇰

2 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lab#2
Task#1:
#include <iostream>
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;
}
pf3
pf4
pf5

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");