diff --git a/C/max.c b/C/max.c new file mode 100644 index 00000000..c4e7b883 --- /dev/null +++ b/C/max.c @@ -0,0 +1,20 @@ +#include +int main(){ + int i,n,max,pos; + printf("Enter the number of elements in the array: "); + scanf("%d",&n); + int a[n]; + printf("Enter array elements: "); + for(i=0;ia[0]){ + pos=i; + max=a[i]; + } + } + printf(" The maximum element of the array is %d",max); +} diff --git a/C/pattern1.c b/C/pattern1.c new file mode 100644 index 00000000..18738460 --- /dev/null +++ b/C/pattern1.c @@ -0,0 +1,22 @@ +#include +#include + +int main(){ + int n,i,j; + char ch='*'; + scanf("%d",&n); + for(i=1;i<=n;i++) + { + for(j=1;j<=n;j++) + { + if(i==1 || j==1 || i==n || j==n) + { + printf("%c",ch); + } + else{ + printf(" "); + } + } + printf("\n"); + } +}