Skip to content

Commit 50737f7

Browse files
Add files via upload
Constant space complexity example in C Constant space complexity means that the amount of memory used by the program does not change with the size of the input. Here's an example of a C program with constant space complexity:
1 parent f42c16c commit 50737f7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: dsa1.c

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include<stdio.h>
2+
3+
int square (int n){
4+
printf("%d Byte\n", sizeof(int));
5+
printf("%d Byte\n", sizeof(n));
6+
return n*n;
7+
}
8+
main(){
9+
int num;
10+
printf("Enter a Number:");
11+
scanf("%d", &num);
12+
int value = square(num);
13+
printf("%d", value);
14+
}

0 commit comments

Comments
 (0)