test
This commit is contained in:
parent
37776af5db
commit
ab03d5f10c
4045 changed files with 286212 additions and 3 deletions
31
.config/Code/User/History/-57ca33c7/1QKo.cpp
Normal file
31
.config/Code/User/History/-57ca33c7/1QKo.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
// Global Variables/functions not allowed
|
||||
|
||||
// Recursive function to calculate the length of a string
|
||||
int getStringLength(char* s){ // Default arguments not allowed
|
||||
if(s[0] == '\0') return 0;
|
||||
else return 1 + getStringLength(s+1);
|
||||
}
|
||||
|
||||
int main() {
|
||||
// Test cases, don't modify
|
||||
string test1 = "123456";
|
||||
string test2 = "moyeMoye";
|
||||
string test3 = ""; // Empty string
|
||||
string test4 = "OOP Lab";
|
||||
string test5 = "Recursion is fun!";
|
||||
|
||||
// You can make modifications down here....//
|
||||
|
||||
cout << " String = " << test1 << ", Expected = 6, Your output = " << getStringLength(&test1[0]) << endl;
|
||||
cout << " String = " << test2 << ", Expected = 8, Your output = " << getStringLength(&test2[0]) << endl;
|
||||
cout << " String = " << test3 << ", Expected = 0, Your output = " << getStringLength(&test3[0]) << endl;
|
||||
cout << " String = " << test4 << ", Expected = 7, Your output = " << getStringLength(&test4[0]) << endl;
|
||||
cout << " String = " << test5 << ", Expected = 17, Your output = " << getStringLength(&test5[0]) << endl;
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
1
.config/Code/User/History/-57ca33c7/entries.json
Normal file
1
.config/Code/User/History/-57ca33c7/entries.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":1,"resource":"file:///home/rafayahmad/Downloads/232526/q1.cpp","entries":[{"id":"1QKo.cpp","timestamp":1717740431705}]}
|
Loading…
Add table
Add a link
Reference in a new issue