int sum(int k) {
if (k > 0) {
return k + sum(k - 1);
} else {
return 0;
}
}
int main() {
int result = sum(10);
cout << result;
return 0;
}
#
##
###
####
#####
######
Code Example |
---|
Cpp :: c++ for each loop |
Cpp :: c++ data types |
Cpp :: sort strings by length and by alphabet |
Cpp :: double array c++ |
Cpp :: comparator priority queue c++ |
Cpp :: selection sort c++ |
Cpp :: c++ check if key exists in map |
Cpp :: c++ uint8_t header |
Cpp :: find text in string c++ true false |
Cpp :: bfs sudocode |
Cpp :: how to convert hexadecimal to decimal in c++ |
Cpp :: cpp oop |
Cpp :: Find duplicates in an array geeks for geeks solution in cpp |
Cpp :: adding variables c++ |
Cpp :: find vector size in c++ |
Cpp :: age in days in c++ |
Cpp :: 344. reverse string c++ |
Cpp :: c++ linked list delete node |
Cpp :: c++ convert to assembly language |
Cpp :: get function in cpp. |
Cpp :: c++ class methods |
Cpp :: count c++ |
Cpp :: how to rotate a matrix 90 degrees clockwise |
Cpp :: pointer to pointer c++ |
Cpp :: queue in cpp |
Cpp :: c++ bit shift wrap |
Cpp :: Consell de forces polítiques de Catalunya |
Cpp :: 41.00 |
Cpp :: C++ Initializing a thread with a class/object |
Cpp :: strcmp in c++ header file |