From b5a4134e8f4dc105961495eaf0336a0cecaaf591 Mon Sep 17 00:00:00 2001 From: Ankita Patra Date: Sun, 16 Oct 2022 23:35:17 +0530 Subject: [PATCH] completed --- .DS_Store | Bin 0 -> 6148 bytes c_programs/goto.c | 19 +++++++++++++++++++ c_programs/maxElementArray.c | 25 +++++++++++++++++++++++++ c_programs/numToBinary.c | 17 +++++++++++++++++ c_programs/staticVar.c | 14 ++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 .DS_Store create mode 100644 c_programs/goto.c create mode 100644 c_programs/maxElementArray.c create mode 100644 c_programs/numToBinary.c create mode 100644 c_programs/staticVar.c diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1a8edad2dae2d217ec6fcd8ed566b2299ffc3052 GIT binary patch literal 6148 zcmeHK%}xR_5S{|cA~E5h3CAX0NkkBh@v=dD0oUk34ekoTjmws>AO}LSXMG``#OHCQ zEk*(!yci=h$@FXIXPbWAbXouq&2i@dpacL8Dq*I8%?cqu>5^oug;3~kDCofueCR{6 z6wQXe$N=r#7Cb;32Do!y_Ai(ugCJ4?`rm><6ego;^<8ALxsA=dlXr^Fo%g6F-pC(~ zlcqnsq0yyMQ84fO!ByCuv`af@DjxY^+#TwKu+znm+v_mys7X_e<4&S;J>zf+PN7{Y zPp6IgaYfcnsm&Jdge2If zw*;ZI=vqt-q6bBoR78_1>=Q$nbhJww=UPk+nsg9)X8ewwS=bkf(6ggm>TnRQL2j7= zW?+$ltQnT5{-1yU{$EVu5i`IH{3`}TuI06wxFlO!mlj90R-)dcl2BY~@G}KFx)ft9 emEtn07PL$1Ai5S)gJ?nFi-4wq8)o2F8TbIAG)>(A literal 0 HcmV?d00001 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(); +}