diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..1a8edad Binary files /dev/null and b/.DS_Store differ diff --git a/c_programs/goto.c b/c_programs/goto.c new file mode 100644 index 0000000..a3a1586 --- /dev/null +++ b/c_programs/goto.c @@ -0,0 +1,19 @@ +#include +int main() +{ + int age; +ineligible: + + printf("Enter your age :\n"); + scanf("%d", &age); + if (age < 18) + { + printf("You are ineligible ...\n"); + goto ineligible; + } + else + { + printf("You are eligible."); + } + return 0; +} \ No newline at end of file diff --git a/c_programs/maxElementArray.c b/c_programs/maxElementArray.c new file mode 100644 index 0000000..5acebf3 --- /dev/null +++ b/c_programs/maxElementArray.c @@ -0,0 +1,25 @@ +#include + +int main() { + + int arr[10],max,i,n; + +printf("Enter the number of elements of array :\n"); + scanf("%d",&n); + printf("Enter the elements :\n"); + for(i = 0;i < n;i++) { + scanf("%d",&arr[i]); + + } + for(i = 0;i arr[0] ) + arr[0]= arr[i]; + + + } + printf( "maximum is %d",arr[0]); + +return 0; + + +} \ No newline at end of file diff --git a/c_programs/numToBinary.c b/c_programs/numToBinary.c new file mode 100644 index 0000000..fdbadf9 --- /dev/null +++ b/c_programs/numToBinary.c @@ -0,0 +1,17 @@ +#include +int main() +{ + int a[10], n, i; + printf("Enter the number to convert: \n"); + scanf("%d",&n); + for (i = 0; n > 0; i++) + { + a[i] = n % 2; + n = n / 2; + } + printf("Binary of the given number= "); + for (i = i - 1; i >= 0; i--) + { + printf("%d",a[i]); + } +} \ No newline at end of file diff --git a/c_programs/staticVar.c b/c_programs/staticVar.c new file mode 100644 index 0000000..4a237f2 --- /dev/null +++ b/c_programs/staticVar.c @@ -0,0 +1,14 @@ +#include +void func() { + static int i=0; //static variable + int j=0; //local variable + i++; + j++; + printf( "%d and %d\n",i,j); +} +int main() +{ + func(); + func(); + func(); +}