From 967f0edeca91aff0a2a33297ef35a9e63f62bcbb Mon Sep 17 00:00:00 2001 From: Swapnita_Singh <127416976+Swapnita06@users.noreply.github.com> Date: Thu, 6 Apr 2023 19:16:54 +0530 Subject: [PATCH] Add files via upload --- EIGHTH.C | 19 ++++++++++++++++++ FIFTH.C | 20 +++++++++++++++++++ FIRST.C | 29 +++++++++++++++++++++++++++ FOURTH.C | 14 +++++++++++++ NINTH.C | 13 ++++++++++++ SECOND.C | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ SEVENTH.C | 19 ++++++++++++++++++ SIXTH.C | 20 +++++++++++++++++++ TENTH.C | 29 +++++++++++++++++++++++++++ THIRD.C | 40 +++++++++++++++++++++++++++++++++++++ 10 files changed, 262 insertions(+) create mode 100644 EIGHTH.C create mode 100644 FIFTH.C create mode 100644 FIRST.C create mode 100644 FOURTH.C create mode 100644 NINTH.C create mode 100644 SECOND.C create mode 100644 SEVENTH.C create mode 100644 SIXTH.C create mode 100644 TENTH.C create mode 100644 THIRD.C diff --git a/EIGHTH.C b/EIGHTH.C new file mode 100644 index 0000000..6114a3b --- /dev/null +++ b/EIGHTH.C @@ -0,0 +1,19 @@ +#include +#include +int main(){ + int i,v=0,c=0; + char str[100]; + printf("Enter the string:"); + gets(str); + for(i = 0; i < strlen(str); i++){ + if(str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u') { + v++; + } + else if(str[i] >= 'a' && str[i] <= 'z'){ + c++; + } + } + printf("Number of vowels : %d\n", v); + printf("Number of consonant : %d", c); + return 0; +} \ No newline at end of file diff --git a/FIFTH.C b/FIFTH.C new file mode 100644 index 0000000..07166c4 --- /dev/null +++ b/FIFTH.C @@ -0,0 +1,20 @@ +#include +int main(){ +int arr[]={1,7,5,3,1}; +int MaxCount=0; +int MaxFreq; +for(int i=0;i<5;i++){ + int count=0; + for(int j=0;j<5;j++){ + int k=arr[i]; + if(arr[j]==k){ + count++; +} + } +if (count >MaxCount){ + MaxCount=count; +MaxFreq = arr[i]; +} +} +printf("The most frequent no is : %d and it has occured %d times",MaxFreq, MaxCount); +} \ No newline at end of file diff --git a/FIRST.C b/FIRST.C new file mode 100644 index 0000000..305d39b --- /dev/null +++ b/FIRST.C @@ -0,0 +1,29 @@ +#include + +int main(){ + int n, i, num, occr = 0; + + printf("Enter the Array size = "); + scanf("%d", &n); + + int arr[n]; + + printf("Enter the %d elements : ", n); + for (i = 0; i < n; i++) + { + scanf("%d", &arr[i]); + } + + printf("Enter the Item to Know = "); + scanf("%d", &num); + + for (i = 0; i < n; i++) + { + if (arr[i] == num) + { + occr++; + } + } + + printf("%d Occurred %d Times.\n", num, occr); +} \ No newline at end of file diff --git a/FOURTH.C b/FOURTH.C new file mode 100644 index 0000000..81dd0d8 --- /dev/null +++ b/FOURTH.C @@ -0,0 +1,14 @@ +#include + +int main(){ + int i,j,num=1; + for(i=0;i<5;i++){ + for (j=0;j<=i;j++){ + printf("%d ", num); + num++; + } + printf("\n"); + } + return 0; +} + \ No newline at end of file diff --git a/NINTH.C b/NINTH.C new file mode 100644 index 0000000..0d913b8 --- /dev/null +++ b/NINTH.C @@ -0,0 +1,13 @@ +#include +int main() { + int i, j, rows; + printf("Enter the number of rows: "); + scanf("%d", &rows); + for (i = rows; i >= 1; --i) { + for (j = 1; j <= i; ++j) { + printf("* "); + } + printf("\n"); + } + return 0; +} diff --git a/SECOND.C b/SECOND.C new file mode 100644 index 0000000..78fbecd --- /dev/null +++ b/SECOND.C @@ -0,0 +1,59 @@ +#include + +int main(){ + int n, m, i= 0; + + printf("Enter the Array1 size = "); + scanf("%d", &n); + + int arr1[n]; + + printf("Enter the %d elements : ", n); + for (i = 0; i < n; i++) + { + scanf("%d", &arr1[i]); + } + + printf("Enter the Array2 size = "); + scanf("%d", &m); + + int arr2[m]; + + printf("Enter the %d elements : ", m); + for (i = 0; i < m; i++) + { + scanf("%d", &arr2[i]); + } + + int totsize = n+m; + + int Mgdarr[totsize]; + + for(i=0; i + +int main(){ +int arr[]={1,2,-9,-6,4,2}; +int j=0; +for(int i=0;i<6;i++){ + if(arr[i]<0){ + if(i!=j){ + int temp=arr[i]; + arr[i]=arr[j]; + arr[j]=temp; + } + j++; + } +} +for(int i=0;i<6;i++){ + printf("%d ", arr[i]); +} +} \ No newline at end of file diff --git a/SIXTH.C b/SIXTH.C new file mode 100644 index 0000000..07166c4 --- /dev/null +++ b/SIXTH.C @@ -0,0 +1,20 @@ +#include +int main(){ +int arr[]={1,7,5,3,1}; +int MaxCount=0; +int MaxFreq; +for(int i=0;i<5;i++){ + int count=0; + for(int j=0;j<5;j++){ + int k=arr[i]; + if(arr[j]==k){ + count++; +} + } +if (count >MaxCount){ + MaxCount=count; +MaxFreq = arr[i]; +} +} +printf("The most frequent no is : %d and it has occured %d times",MaxFreq, MaxCount); +} \ No newline at end of file diff --git a/TENTH.C b/TENTH.C new file mode 100644 index 0000000..606e344 --- /dev/null +++ b/TENTH.C @@ -0,0 +1,29 @@ +#include +#include + +int main() +{ + char s[100]; + int i,k,alpha=0,digit=0,spchar=0; + + printf("Enter the string : "); + gets(s); + + k=strlen(s); + + for(i=0;i=65 && s[i]<=90)|| (s[i]>=97 && s[i]<=122) ) + alpha++; + else if(s[i]>=48 && s[i]<=57) + digit++; + else + spchar++; + + } + + + printf("Alphabets = %d\n",alpha); + printf("Digits = %d\n",digit); + printf("Special characters = %d", spchar); + return 0; +} \ No newline at end of file diff --git a/THIRD.C b/THIRD.C new file mode 100644 index 0000000..f8ca851 --- /dev/null +++ b/THIRD.C @@ -0,0 +1,40 @@ +#include +#include + +int sort(int *a,int n); +int print(int *a,int n); + + +int main(){ + int a[100],i,n; + + printf("Enter size of the array : "); + scanf("%d", &n); + printf("Enter elements in array : "); + for(i=0; ia[j+1]){ + temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp;} + } + } +} +int print(int *a,int n){ + int i; + for(i=0; i