Dayananda Sagar College of Engineering 2023
My Stats
EXP gained
3060
Level
5 (Champion)
Community stats
Discussions
1
0
Know more
Weekend contest rating
Contest attended
Problems solved
2021 2023
Better than %
Weekend contest rating
Contest attended
Problems solved
2021 2023
Better than %
143
Total problems solved
138
Easy
5
Moderate
0
Hard
0
Ninja

Current streak:

0 days

Longest streak:

4 days

Less

More

Achievements
1
Ronin
Guided path
Basics of C++
Discussions
c++
Interview problems
``````#include <iostream>
using namespace std;

int main() {
int run;
cin >> run;
int array[run];
int array1[run];
for(int i=0;i<run;i++){
cin>>array[i];
}
/*for(int i=0;i<run;i++){
cout<<array[i] <<" ";
}*/
for (int i=run-1;i>=0;i--){
cout<<array[i]<<" ";
}
return 0;
}``````
Karthik2001_s
Published On 09-Jan-2023
59 views
0 replies
c++
Interview problems
``````#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int index(int arr[],int find,int run){
int i;//first_selection;
for(i=0;i<run;i++){
if(arr[i]==find) {
return i;
break;
}
}
return -1;
}
int main() {
int find,run,x;
cin >> run;
int array[run];
for(int i=0;i<run;i++){
cin >> array[i];
}
cin >> find;
int results1 = index(array,find,run);
//cout << results1;
if (results1!=-1){
for (int i=results1;i<run;i++){
if(array[i]==find) x=i;
}
cout <<x;
}
else cout << results1;
}``````
Karthik2001_s
Published On 09-Jan-2023
39 views
0 replies