From 27dbeef59fd3e2ea135eee9d06c7f026549afbba Mon Sep 17 00:00:00 2001 From: patro-12 <127765647+patro-12@users.noreply.github.com> Date: Tue, 4 Apr 2023 22:14:06 +0530 Subject: [PATCH 1/2] Add files via upload --- q1 loc assignment 2 | 24 ++++++++++++++++++++++++ q10 loc assignment 2 | 21 +++++++++++++++++++++ q2 loc assignment 2 | 40 ++++++++++++++++++++++++++++++++++++++++ q3 loc assignment 2 | 33 +++++++++++++++++++++++++++++++++ q4 loc assignment 2 | 15 +++++++++++++++ q5 loc assignment 5 | 30 ++++++++++++++++++++++++++++++ q6 loc assignment 2 | 21 +++++++++++++++++++++ q8 loc assignment 2 | 18 ++++++++++++++++++ q9 loc assignment 2 | 16 ++++++++++++++++ 9 files changed, 218 insertions(+) create mode 100644 q1 loc assignment 2 create mode 100644 q10 loc assignment 2 create mode 100644 q2 loc assignment 2 create mode 100644 q3 loc assignment 2 create mode 100644 q4 loc assignment 2 create mode 100644 q5 loc assignment 5 create mode 100644 q6 loc assignment 2 create mode 100644 q8 loc assignment 2 create mode 100644 q9 loc assignment 2 diff --git a/q1 loc assignment 2 b/q1 loc assignment 2 new file mode 100644 index 0000000..7b4955f --- /dev/null +++ b/q1 loc assignment 2 @@ -0,0 +1,24 @@ +#include +int main() +{ + int size,i,num,occur=0; + printf("Enter the array size="); + scanf("%d",size); + int arr[size]; + prinf("Enter the array %d elements:",size); + for(i=0;i +void main() +{ + clrscr(); + char s[100]; + int alp=0, digit=0,spcl=0,i=0; + printf("enter a string"); + gets(s); + while(s[i]!='/0') + { + if((s[i]>='a')&&(s[i]<='z')!!(s[i]>='A')&&(s[i]<='Z')) + { + alp++; + } + if(s[i]) + i++; + } + + } + } +} \ No newline at end of file diff --git a/q2 loc assignment 2 b/q2 loc assignment 2 new file mode 100644 index 0000000..d159b3f --- /dev/null +++ b/q2 loc assignment 2 @@ -0,0 +1,40 @@ +#include +int main() +{ + int s1,s2,s3,arr1,arr2,arr3,k,j,i,t; + printf("enter the size of first array"); + scanf("%d,s1"); + printf("enter the size of second array"); + scanf("%d,s2"); + s3=s1+s2; + printf("enter elements of first array"); + int arr1[s1],arr2[s2],arr3[s3]; + for(int i=0;iarr3[j]) + { + t=arr3[i]; + arr3[i]=arr3[j]; + arr3[j]=t; + } + } + } +for(int i=0;i +void main() +{ + int a[10],i,n; + printf("enter a number"); + scanf("%d,n"); + for(i=0;ia[j]) + { + t=a[i]; + a[i]=a[j]; + a[j]=t; + } +} +} + diff --git a/q4 loc assignment 2 b/q4 loc assignment 2 new file mode 100644 index 0000000..3c1edf6 --- /dev/null +++ b/q4 loc assignment 2 @@ -0,0 +1,15 @@ +#include +main() +{ + int i,j,count; + for(i=0;i<=5;i++) + { + for(j=1;j<=i;j++) + { + printf("%d",count); + + } + printf("/n"); + } + +} \ No newline at end of file diff --git a/q5 loc assignment 5 b/q5 loc assignment 5 new file mode 100644 index 0000000..abe9ec8 --- /dev/null +++ b/q5 loc assignment 5 @@ -0,0 +1,30 @@ +#include +void main() +{ + int a1[100],a2[100],i,n; + clrscr(); + printf("enter size of array"); + scanf("%d",&n); + printf("enter array elements"); + for(i=0;i +int main() +{ + int a[],size,i,max; + printf("enter size of array"); + scanf("%d",&size); + for(int i=0;imax) + { + max=a[i]; + + } + } + +} \ No newline at end of file diff --git a/q8 loc assignment 2 b/q8 loc assignment 2 new file mode 100644 index 0000000..7714c82 --- /dev/null +++ b/q8 loc assignment 2 @@ -0,0 +1,18 @@ +#include +#include +#include +void main() +{ + char str[50]; + int l,v=0,c=0; + printf("enter a string"); + gets(str); + l=strlen(str); + for(i=0;i<=l;i++) + { + if(str[i]>='a'&&str[i]<='z'!!str[i]>='A'&&str[i]<='z') + if(str[i]=='a'!!str[i]=='i'!!str[i]=='o'!!str[i]=='e'!!str[i]=='u'!!str[i]=='A'!!str[i]=='O'!!str[i]=='U'!!str[i]=='I'!!str[i]=='E') + printf("no of vowels=%d",v); + printf("no of consonants=%d",c); + getch(); +} \ No newline at end of file diff --git a/q9 loc assignment 2 b/q9 loc assignment 2 new file mode 100644 index 0000000..0f47558 --- /dev/null +++ b/q9 loc assignment 2 @@ -0,0 +1,16 @@ +#include +int main() +{ + int i,j; + for(i=1;i<=5;i++) + { + for(j=5;j>=i;j--) + { + printf("*"); + + } + printf("/n"); + + } +return 0; +} \ No newline at end of file From 0ee0076a76f93d240919ed0001470a93fd831d7f Mon Sep 17 00:00:00 2001 From: patro-12 <127765647+patro-12@users.noreply.github.com> Date: Sun, 9 Apr 2023 20:12:52 +0530 Subject: [PATCH 2/2] Add files via upload --- loc_week_3_que_ 2.c | 28 ++++++++++++++++++++++++++++ loc_week_3_ques_1.c | 29 +++++++++++++++++++++++++++++ loc_week_3_ques_3.c | 14 ++++++++++++++ loc_week_3_ques_4.c | 29 +++++++++++++++++++++++++++++ loc_week_3_ques_5.c | 9 +++++++++ loc_week_3_ques_6.c | 1 + loc_week_4_ques_7.c | 3 +++ 7 files changed, 113 insertions(+) create mode 100644 loc_week_3_que_ 2.c create mode 100644 loc_week_3_ques_1.c create mode 100644 loc_week_3_ques_3.c create mode 100644 loc_week_3_ques_4.c create mode 100644 loc_week_3_ques_5.c create mode 100644 loc_week_3_ques_6.c create mode 100644 loc_week_4_ques_7.c diff --git a/loc_week_3_que_ 2.c b/loc_week_3_que_ 2.c new file mode 100644 index 0000000..5ee512b --- /dev/null +++ b/loc_week_3_que_ 2.c @@ -0,0 +1,28 @@ +#include +#include +int main() +{ + char str[100]; + int i,totalchar; + totalchar=0; + print("please enter the string characters to count"); + gets(str); + i=0; + while(str[i]!="/0"); + { +if(str[i]!='char') + { + totalchar++; + + } + i++; + } + printf("the total characters of string is=%d",totalchar); + getch(); + return 0; +} + + + + + diff --git a/loc_week_3_ques_1.c b/loc_week_3_ques_1.c new file mode 100644 index 0000000..0095d89 --- /dev/null +++ b/loc_week_3_ques_1.c @@ -0,0 +1,29 @@ +#include +#include +int main() +{ +char str[100],chr; +int i,len,j; +printf("Enter any string"); +gets(str); + +printf("Enter the character to remove"); +scanf("%c",&chr); +len=strlen(len); + +for(i=0;i +int main() +{ + int fst,sec,*p,*q,sum; + printf("enter two integers to add"); + scanf("%d%d",&fst,&sec); + p=&fst; + q=&sec; + sum=*p+*q; + printf("sum of entered nos=%d",sum); + return 0; + + +} diff --git a/loc_week_3_ques_4.c b/loc_week_3_ques_4.c new file mode 100644 index 0000000..cc7db7e --- /dev/null +++ b/loc_week_3_ques_4.c @@ -0,0 +1,29 @@ +#include +#include +long int fact(int n); +int main() +{ + int n; + long int f; + printf("enter a positive number"); + scanf("%d",&n); + f=fact(n); + printf("factorial of %d=%ld",n,f); + getch(); + return 0; + +} +long int fact(int n); +{ + long int f; + + if(n>=1) + { + f=n*fact(n-1); + return f; + + } + else + return 1; + +} \ No newline at end of file diff --git a/loc_week_3_ques_5.c b/loc_week_3_ques_5.c new file mode 100644 index 0000000..cb1eaeb --- /dev/null +++ b/loc_week_3_ques_5.c @@ -0,0 +1,9 @@ +void main() +{ + int k=5; + int *p=&k; + int **m=&p; + **m=6; + printf("%d",k); +} + diff --git a/loc_week_3_ques_6.c b/loc_week_3_ques_6.c new file mode 100644 index 0000000..9eed1e3 --- /dev/null +++ b/loc_week_3_ques_6.c @@ -0,0 +1 @@ +//structure members cannot be initialized at time of declaration. diff --git a/loc_week_4_ques_7.c b/loc_week_4_ques_7.c new file mode 100644 index 0000000..8cda37d --- /dev/null +++ b/loc_week_4_ques_7.c @@ -0,0 +1,3 @@ +/*size is to calculate the size of variables,structure,pointers or datatypes. +data types could be pre defined or user defined. +we can calculate the size of structure straightforward to pass it as parameter.*/