Considering the given code as an algorithm calculate the time complexity of this code.

#include<iostream>
#include<stdlib.h>
using namespace std;


int main(){
int i, j, n;
for(i=0;i<n; i++){


for(j=0; j<n; j++){
cout<<"my time complexity is = "<<i*j<<endl;
}
cout<<"complexity is increasing"<<j<<endl;
}
system("pause");
return 0;
}

Well, you demonstrate absolutely senseless code (n is not initialized).
And what's your question?

Considering the given code as an algorithm calculate the time complexity of this code.

#include<iostream>
#include<stdlib.h>
using namespace std;

int main(){
int i, j, n;
for(i=0;i<n; i++){

for(j=0; j<n; j++){
cout<<"my time complexity is = "<<i*j<<endl;
}
cout<<"complexity is increasing"<<j<<endl;
}
system("pause");
return 0;
}

Code tags please

[/[TEX]][/TEX]code]. Also if our asking what the time complexity is. Why don't you consider showing us what you understand before we just tell you.

Also it should be cstdlib, since this is cplusplus

[CODE=cplusplus]#include<iostream>
#include<cstdlib>
using namespace std;

int main(){
    int i, j, n;
for(i=0;i<n; i++){

        for(j=0; j<n; j++){
                cout<<"my time complexity is = "<<i*j<<endl;
                }
        cout<<"complexity is increasing"<<j<<endl;
        }
system("pause");
return 0;
}

But indeed agreein with ArkM what is n?

Chris

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.