diff --git a/File handling/dat file.c b/File handling/dat file.c new file mode 100644 index 0000000..ceeed57 --- /dev/null +++ b/File handling/dat file.c @@ -0,0 +1,20 @@ +#include +struct bank +{ + int bookid; + char name[25]; + float rate; +}; +main() +{ + struct bank b1; + FILE *fp; + fp=fopen("f5.dat","wb"); + printf("Enter bookid name and rate:\n"); + scanf("%d",&b1.bookid); + fflush(stdin); + gets(b1.name); + scanf("%f",&b1.rate); + fwrite(&b1,sizeof(b1),1,fp); + fclose(fp); +} diff --git a/File handling/dat file.exe b/File handling/dat file.exe new file mode 100644 index 0000000..5970554 Binary files /dev/null and b/File handling/dat file.exe differ diff --git a/File handling/dat file.o b/File handling/dat file.o new file mode 100644 index 0000000..c0f0d9f Binary files /dev/null and b/File handling/dat file.o differ diff --git a/File handling/f1.c b/File handling/f1.c new file mode 100644 index 0000000..abb6147 --- /dev/null +++ b/File handling/f1.c @@ -0,0 +1,18 @@ +#include +main() +{ + int i; + FILE *fp; + char str[]="Amee Computer class Batch 1 sneh"; + fp=fopen("f1.txt","w"); + if(fp==NULL) + { + printf("File cannot be opened.\n"); + exit(1); + } + for(i=0;i +main() +{ + char ch[20]; + FILE *fp; + fp=fopen("juju1.txt","w"); + if(fp==NULL) + { + printf("File not found.\n"); + exit(1); + } + printf("Enter string:\n"); + gets(ch); + fputs(ch,fp); + fclose(fp); +} diff --git a/File handling/fputs.exe b/File handling/fputs.exe new file mode 100644 index 0000000..52d28b4 Binary files /dev/null and b/File handling/fputs.exe differ diff --git a/File handling/fputs.o b/File handling/fputs.o new file mode 100644 index 0000000..d0de9d3 Binary files /dev/null and b/File handling/fputs.o differ diff --git a/File handling/juju.txt b/File handling/juju.txt new file mode 100644 index 0000000..3d3a8ee --- /dev/null +++ b/File handling/juju.txt @@ -0,0 +1 @@ +Sneh chauhan diff --git a/File handling/juju1.txt b/File handling/juju1.txt new file mode 100644 index 0000000..c9cf76b --- /dev/null +++ b/File handling/juju1.txt @@ -0,0 +1 @@ +snehchauhan \ No newline at end of file diff --git a/File handling/reading from a file using fgets.c b/File handling/reading from a file using fgets.c new file mode 100644 index 0000000..d590cf3 --- /dev/null +++ b/File handling/reading from a file using fgets.c @@ -0,0 +1,18 @@ +/*To read from a file using fgets() */ +#include +main() +{ + char ch[20]; + FILE *fp; + fp=fopen("juju.txt","r"); + if(fp==NULL) + { + printf("File not found.\n"); + exit(1); + } + while(fgets(ch,8,fp)!=NULL) + { + printf("%s",ch); + } + fclose(fp); +} diff --git a/File handling/reading from a file using fgets.exe b/File handling/reading from a file using fgets.exe new file mode 100644 index 0000000..f3e3e3a Binary files /dev/null and b/File handling/reading from a file using fgets.exe differ diff --git a/File handling/reading from a file using fgets.o b/File handling/reading from a file using fgets.o new file mode 100644 index 0000000..32e5b67 Binary files /dev/null and b/File handling/reading from a file using fgets.o differ diff --git a/File handling/sns.c b/File handling/sns.c new file mode 100644 index 0000000..3b2239e --- /dev/null +++ b/File handling/sns.c @@ -0,0 +1,19 @@ +#include +main() +{ + char ch; + FILE *fp; + fp=fopen("juju.txt","r"); + if(fp==NULL) + { + printf("File not found.\n"); + exit(0); + } + ch=fgetc(fp); + while(!feof(fp)) + { + printf("%c",ch); + ch=fgetc(fp); //Recursion + } + fclose(fp); +} diff --git a/File handling/sns.exe b/File handling/sns.exe new file mode 100644 index 0000000..e0c2263 Binary files /dev/null and b/File handling/sns.exe differ diff --git a/File handling/sns.o b/File handling/sns.o new file mode 100644 index 0000000..11b400f Binary files /dev/null and b/File handling/sns.o differ diff --git a/Functions/areaofcircle.c b/Functions/areaofcircle.c new file mode 100644 index 0000000..7625bc3 --- /dev/null +++ b/Functions/areaofcircle.c @@ -0,0 +1,17 @@ +#include +#define PI 3.14 +float areac(float); +int main() +{ + float r; + printf("Enter the radius of Circle:\n"); + scanf("%f",&r); + printf("The Area of the circle with radius %f is: %f",r,areac(r)); + return 0; +} +float areac(float r) +{ + float z; + z=PI*r*r; + return z; +} diff --git a/Functions/areaofcircle.exe b/Functions/areaofcircle.exe new file mode 100644 index 0000000..137e814 Binary files /dev/null and b/Functions/areaofcircle.exe differ diff --git a/Functions/areaofcircle.o b/Functions/areaofcircle.o new file mode 100644 index 0000000..62f5c75 Binary files /dev/null and b/Functions/areaofcircle.o differ diff --git a/Functions/dectobin.c b/Functions/dectobin.c new file mode 100644 index 0000000..8a542ed --- /dev/null +++ b/Functions/dectobin.c @@ -0,0 +1,23 @@ +#include +int dec(int); +main() +{ + int x,i; + printf("Enter the value of x:\n"); + scanf("%d",&x); + dec(x); +} +int dec(x) +{ + int i,bin[15]; + for(i=0;i<15;i++) + { + bin[i]=x%2; + x=x/2; + } + printf("The Binary value is:\n"); + for(i=14;i>=0;i--) + { + printf("%d",bin[i]); + } +} diff --git a/Functions/dectobin.exe b/Functions/dectobin.exe new file mode 100644 index 0000000..7ea176c Binary files /dev/null and b/Functions/dectobin.exe differ diff --git a/Functions/dectobin.o b/Functions/dectobin.o new file mode 100644 index 0000000..069e8ad Binary files /dev/null and b/Functions/dectobin.o differ diff --git a/Functions/factorial.c b/Functions/factorial.c new file mode 100644 index 0000000..4219b3f --- /dev/null +++ b/Functions/factorial.c @@ -0,0 +1,20 @@ +#include +int fact(int x); +int main() +{ + int x; + printf("Enter the value of x:\n"); + scanf("%d",&x); + //z=fact(x); + printf("The factorial of x is :%d",fact(x)); + return 0; +} +int fact(int x) +{ + int i,fact=1; + for(i=x;i>=1;i--) + { + fact*=i; + } + return fact; +} diff --git a/Functions/factorial.exe b/Functions/factorial.exe new file mode 100644 index 0000000..16dd29c Binary files /dev/null and b/Functions/factorial.exe differ diff --git a/Functions/factorial.o b/Functions/factorial.o new file mode 100644 index 0000000..642bb68 Binary files /dev/null and b/Functions/factorial.o differ diff --git a/Functions/factors.c b/Functions/factors.c new file mode 100644 index 0000000..54f75ee --- /dev/null +++ b/Functions/factors.c @@ -0,0 +1,21 @@ +#include +void factors(int); +main() +{ + int x; + printf("Enter the value of x:\n"); + scanf("%d",&x); + factors(x); +} +void factors(int x) +{ + int i; + for(i=1;i<=x;i++) + { + if(x%i==0) + { + printf("%d",i); + } + + } +} diff --git a/Functions/factors.exe b/Functions/factors.exe new file mode 100644 index 0000000..766e367 Binary files /dev/null and b/Functions/factors.exe differ diff --git a/Functions/factors.o b/Functions/factors.o new file mode 100644 index 0000000..ec8189d Binary files /dev/null and b/Functions/factors.o differ diff --git a/Functions/functions.c b/Functions/functions.c new file mode 100644 index 0000000..c784936 --- /dev/null +++ b/Functions/functions.c @@ -0,0 +1,28 @@ +#include +void italy(); +void germany(); +void india(); + +main() +{ + printf("I am in main.\n"); + italy(); + printf("I am back in main.\n"); +} +void italy() +{ + printf("I am in ITALY.\n"); + germany(); + printf("I am back in ITALY.\n"); +} +void germany() +{ + printf("I am in GERMANY.\n"); + india(); + printf("I am back in GERMANY.\n"); +} +void india() +{ + printf("I am in INDIA.\n"); +} + diff --git a/Functions/functions.exe b/Functions/functions.exe new file mode 100644 index 0000000..d9ebde5 Binary files /dev/null and b/Functions/functions.exe differ diff --git a/Functions/functions.o b/Functions/functions.o new file mode 100644 index 0000000..b56b9ca Binary files /dev/null and b/Functions/functions.o differ diff --git a/Functions/functions1.c b/Functions/functions1.c new file mode 100644 index 0000000..9f183f5 --- /dev/null +++ b/Functions/functions1.c @@ -0,0 +1,17 @@ +#include +main() +{ + int sum(int x,int y); + int x,y,s; + printf("Enter x:\n"); + scanf("%d",&x); + printf("Enter y:\n"); + scanf("%d",&y); + s=sum(x,y); + printf("The sum is %d.\n",s); +} +sum(a,b) +{ + int z; + z=a+b; +} diff --git a/Functions/functions1.exe b/Functions/functions1.exe new file mode 100644 index 0000000..3510402 Binary files /dev/null and b/Functions/functions1.exe differ diff --git a/Functions/functions1.o b/Functions/functions1.o new file mode 100644 index 0000000..ce0672e Binary files /dev/null and b/Functions/functions1.o differ diff --git a/Functions/lcm.c b/Functions/lcm.c new file mode 100644 index 0000000..fbe54d2 --- /dev/null +++ b/Functions/lcm.c @@ -0,0 +1,29 @@ +#include +int lcm(int,int); +main() +{ + int x,y; + printf("Enter the value of x:\n"); + scanf("%d",&x); + printf("Enter the value of y:\n"); + scanf("%d",&y); + if(x +int sum(int,int); +main() +{ + int x,y,a; + printf("Enter the value of x:\n"); + scanf("%d",&x); + printf("Enter the value of y:\n"); + scanf("%d",&y); + a=sum(x,y); + printf("The sum of x and y is %d.\n",a); +} + int sum(int x,int y) +{ + int z; + z=x*y; + return z; +} diff --git a/Functions/multiply2values.exe b/Functions/multiply2values.exe new file mode 100644 index 0000000..996d71c Binary files /dev/null and b/Functions/multiply2values.exe differ diff --git a/Functions/multiply2values.o b/Functions/multiply2values.o new file mode 100644 index 0000000..eae93cd Binary files /dev/null and b/Functions/multiply2values.o differ diff --git a/Functions/oddoreven.c b/Functions/oddoreven.c new file mode 100644 index 0000000..364ef79 --- /dev/null +++ b/Functions/oddoreven.c @@ -0,0 +1,17 @@ +#include +int check(int); +int main() +{ + int x; + printf("Enter the number:\n"); + scanf("%d",&x); + return check(x); +} +int check(int x) +{ + int i; + if(x%2==0) + return 1; + else + return 0; +} diff --git a/Functions/oddoreven.exe b/Functions/oddoreven.exe new file mode 100644 index 0000000..719c683 Binary files /dev/null and b/Functions/oddoreven.exe differ diff --git a/Functions/oddoreven.o b/Functions/oddoreven.o new file mode 100644 index 0000000..23eef43 Binary files /dev/null and b/Functions/oddoreven.o differ diff --git a/Functions/primeornot.c b/Functions/primeornot.c new file mode 100644 index 0000000..8856cf9 --- /dev/null +++ b/Functions/primeornot.c @@ -0,0 +1,24 @@ +#include +int prime(int); +main() +{ + int x,z; + printf("Enter the value of x:\n"); + scanf("%d",&x); + z=prime(x); + if(z==1) + printf("The number is not a prime number.\n"); + else + printf("The number is a prime number.\n"); +} +int prime(int x) +{ + int num; + for(int i=2;i<=x-1;i++) + { + if(x%i==0) + return 1; + else + return 0; + } +} diff --git a/Functions/primeornot.exe b/Functions/primeornot.exe new file mode 100644 index 0000000..3490b03 Binary files /dev/null and b/Functions/primeornot.exe differ diff --git a/Functions/primeornot.o b/Functions/primeornot.o new file mode 100644 index 0000000..1fcdc45 Binary files /dev/null and b/Functions/primeornot.o differ diff --git a/Functions/printnaturalnos.c b/Functions/printnaturalnos.c new file mode 100644 index 0000000..de7306c --- /dev/null +++ b/Functions/printnaturalnos.c @@ -0,0 +1,16 @@ +#include +int numbers(int); +int main() +{ + int x; + printf("Enter the number upto which you want to print the numbers from 1:\n"); + scanf("%d",&x); + numbers(x); + return 0; +} +int numbers(int x) +{ + int i; + for(i=1;i<=x;i++) + printf("%d\t",i); +} diff --git a/Functions/printnaturalnos.exe b/Functions/printnaturalnos.exe new file mode 100644 index 0000000..9e68ae1 Binary files /dev/null and b/Functions/printnaturalnos.exe differ diff --git a/Functions/printnaturalnos.o b/Functions/printnaturalnos.o new file mode 100644 index 0000000..e5f1245 Binary files /dev/null and b/Functions/printnaturalnos.o differ diff --git a/Functions/sumof2numbers.c b/Functions/sumof2numbers.c new file mode 100644 index 0000000..3054dd5 --- /dev/null +++ b/Functions/sumof2numbers.c @@ -0,0 +1,20 @@ +/*Use of functions*/ +#include +main() +{ + float sum(float,float); + float x,y,a; + printf("Enter the value of x:\n"); + scanf("%f",&x); + printf("Enter the value of y:\n"); + scanf("%f",&y); + a=x+y; + a=sum(x,y); + printf("The sum of x and y is %f.\n",a); +} +float sum(float x,float y) +{ + float z; + z=x+y; + return z; +} diff --git a/Functions/sumof2numbers.exe b/Functions/sumof2numbers.exe new file mode 100644 index 0000000..0be5028 Binary files /dev/null and b/Functions/sumof2numbers.exe differ diff --git a/Recursion/factorial.c b/Recursion/factorial.c new file mode 100644 index 0000000..5a97099 --- /dev/null +++ b/Recursion/factorial.c @@ -0,0 +1,19 @@ +#include +int sum(int); +main() +{ + int x,z; + printf("Enter the value of x:\n"); + scanf("%d",&x); + z=sum(x); + printf("The sum of %d numbers is %d.\n",x,z); +} +int sum(int a) +{ + int s; + if(a==1) + return(a); + s=a*sum(a-1); + return(s); +} + diff --git a/Recursion/factorial.exe b/Recursion/factorial.exe new file mode 100644 index 0000000..569e13b Binary files /dev/null and b/Recursion/factorial.exe differ diff --git a/Recursion/factorial.o b/Recursion/factorial.o new file mode 100644 index 0000000..79c55bc Binary files /dev/null and b/Recursion/factorial.o differ diff --git a/Recursion/gcd.c b/Recursion/gcd.c new file mode 100644 index 0000000..054f16a --- /dev/null +++ b/Recursion/gcd.c @@ -0,0 +1,22 @@ +#include +int gcd(int,int); +int min; +main() +{ + int x,y; + printf("Enter the value of x:\n"); + scanf("%d",&x); + printf("Enter the value of y:\n"); + scanf("%d",&y); + min=x>y?y:x; + printf("The GCD of %d and %d is %d.\n",x,y,gcd(x,y)); +} +int gcd(int a,int b) +{ + if(a%min==0&&b%min==0) + { + return min; + } + min--; + gcd(a,b); +} diff --git a/Recursion/gcd.exe b/Recursion/gcd.exe new file mode 100644 index 0000000..66203cb Binary files /dev/null and b/Recursion/gcd.exe differ diff --git a/Recursion/gcd.o b/Recursion/gcd.o new file mode 100644 index 0000000..c32152f Binary files /dev/null and b/Recursion/gcd.o differ diff --git a/Recursion/lcm.c b/Recursion/lcm.c new file mode 100644 index 0000000..208301e --- /dev/null +++ b/Recursion/lcm.c @@ -0,0 +1,22 @@ +#include +int lcm(int,int); +main() +{ + int x,y,ans; + printf("Enter the value of x:\n"); + scanf("%d",&x); + printf("Enter the value of y:\n"); + scanf("%d",&y); + ans=lcm(x,y); + printf("The lcm of %d and %d is %d.\n",x,y,ans); +} +int lcm(int a,int b) +{ + static int comm=1;//value of comm remains present till the end of programs i.e it doesn't get overwrite. + if(comm%a==0&&comm%b==0) + { + return comm; + } + comm++; + lcm(a,b); +} diff --git a/Recursion/lcm.exe b/Recursion/lcm.exe new file mode 100644 index 0000000..6935139 Binary files /dev/null and b/Recursion/lcm.exe differ diff --git a/Recursion/lcm.o b/Recursion/lcm.o new file mode 100644 index 0000000..7ce0fe7 Binary files /dev/null and b/Recursion/lcm.o differ diff --git a/Recursion/lcm1.c b/Recursion/lcm1.c new file mode 100644 index 0000000..6303d29 --- /dev/null +++ b/Recursion/lcm1.c @@ -0,0 +1,23 @@ +#include +int lcm(int,int); +int max; +main() +{ + int x,y,z; + printf("Enter the value of x:\n"); + scanf("%d",&x); + printf("Enter the value of y:\n"); + scanf("%d",&y); + max=x>y?x:y; + z=lcm(x,y); + printf("The lcm of %d and %d is %d.\n",x,y,z); +} +int lcm(int a,int b) +{ + if(max%a==0&&max%b==0) + { + return max; + } + max++; + lcm(a,b); +} diff --git a/Recursion/lcm1.exe b/Recursion/lcm1.exe new file mode 100644 index 0000000..50a2e25 Binary files /dev/null and b/Recursion/lcm1.exe differ diff --git a/Recursion/lcm1.o b/Recursion/lcm1.o new file mode 100644 index 0000000..537d885 Binary files /dev/null and b/Recursion/lcm1.o differ diff --git a/Recursion/power.c b/Recursion/power.c new file mode 100644 index 0000000..a54ae53 --- /dev/null +++ b/Recursion/power.c @@ -0,0 +1,21 @@ +#include +int power(int,int); +main() +{ + int x,y,z; + printf("Enter the value of x:\n"); + scanf("%d",&x); + printf("Enter the value of y:\n"); + scanf("%d",&y); + z=power(x,y); + printf("The answer is %d.",z); +} +int power(int a,int b) +{ + int s; + if(b==1) + return a; + s=a*power(a,b-1); + return s; +} + diff --git a/Recursion/power.exe b/Recursion/power.exe new file mode 100644 index 0000000..e2b1c0c Binary files /dev/null and b/Recursion/power.exe differ diff --git a/Recursion/power.o b/Recursion/power.o new file mode 100644 index 0000000..f0dc484 Binary files /dev/null and b/Recursion/power.o differ diff --git a/Recursion/sumofn.c b/Recursion/sumofn.c new file mode 100644 index 0000000..a81b61b --- /dev/null +++ b/Recursion/sumofn.c @@ -0,0 +1,18 @@ +#include +int sum(int); +main() +{ + int x,z; + printf("Enter the value of x:\n"); + scanf("%d",&x); + z=sum(x); + printf("The sum of %d numbers is %d.\n",x,z); +} +int sum(int a) +{ + int s; + if(a==1) + return(a); + s=a+sum(a-1); + return(s); +} diff --git a/Recursion/sumofn.exe b/Recursion/sumofn.exe new file mode 100644 index 0000000..f61fc76 Binary files /dev/null and b/Recursion/sumofn.exe differ diff --git a/Recursion/sumofn.o b/Recursion/sumofn.o new file mode 100644 index 0000000..13bd5b9 Binary files /dev/null and b/Recursion/sumofn.o differ diff --git a/Stringfunctions/strcat.c b/Stringfunctions/strcat.c new file mode 100644 index 0000000..7792375 --- /dev/null +++ b/Stringfunctions/strcat.c @@ -0,0 +1,12 @@ +#include +main() +{ + int i; + char c[20],s[20]; + printf("Enter the string 1:\n"); + gets(c); + printf("Enter the string 2:\n"); + gets(s); + printf("The new combined string is %s.\n",strcat(c,s)); +} + diff --git a/Stringfunctions/strcat.exe b/Stringfunctions/strcat.exe new file mode 100644 index 0000000..71bdf94 Binary files /dev/null and b/Stringfunctions/strcat.exe differ diff --git a/Stringfunctions/strcat.o b/Stringfunctions/strcat.o new file mode 100644 index 0000000..59e89d7 Binary files /dev/null and b/Stringfunctions/strcat.o differ diff --git a/Stringfunctions/strcmp.c b/Stringfunctions/strcmp.c new file mode 100644 index 0000000..5dc0b6a --- /dev/null +++ b/Stringfunctions/strcmp.c @@ -0,0 +1,15 @@ +#include +main() +{ + int i; + char c[20],s[20]; + printf("Enter the string 1:\n"); + gets(c); + printf("Enter the string 2:\n"); + gets(s); + i=strcmp(s,c); + if(i==0) + printf("The strings are same.\n"); + else + printf("The strings are different.\n"); +} diff --git a/Stringfunctions/strcmp.exe b/Stringfunctions/strcmp.exe new file mode 100644 index 0000000..165ec3a Binary files /dev/null and b/Stringfunctions/strcmp.exe differ diff --git a/Stringfunctions/strcmp.o b/Stringfunctions/strcmp.o new file mode 100644 index 0000000..2f023c1 Binary files /dev/null and b/Stringfunctions/strcmp.o differ diff --git a/Stringfunctions/strcpy.c b/Stringfunctions/strcpy.c new file mode 100644 index 0000000..1b0ada3 --- /dev/null +++ b/Stringfunctions/strcpy.c @@ -0,0 +1,8 @@ +#include +main() +{ + char c[20],s[20]; + printf("Enter the string:\n"); + gets(c); + printf("The string is %s.",strcpy(s,c)); +} diff --git a/Stringfunctions/strcpy.exe b/Stringfunctions/strcpy.exe new file mode 100644 index 0000000..4323a62 Binary files /dev/null and b/Stringfunctions/strcpy.exe differ diff --git a/Stringfunctions/strcpy.o b/Stringfunctions/strcpy.o new file mode 100644 index 0000000..3424133 Binary files /dev/null and b/Stringfunctions/strcpy.o differ diff --git a/Stringfunctions/strlen.c b/Stringfunctions/strlen.c new file mode 100644 index 0000000..1a2b77d --- /dev/null +++ b/Stringfunctions/strlen.c @@ -0,0 +1,8 @@ +#include +main() +{ + char c[20]; + printf("Enter the String:\n"); + gets(c); + printf("The length of the Inputted String is %d.\n",strlen(c)); +} diff --git a/Stringfunctions/strlen.exe b/Stringfunctions/strlen.exe new file mode 100644 index 0000000..246d962 Binary files /dev/null and b/Stringfunctions/strlen.exe differ diff --git a/Stringfunctions/strlen.o b/Stringfunctions/strlen.o new file mode 100644 index 0000000..6792572 Binary files /dev/null and b/Stringfunctions/strlen.o differ diff --git a/Stringfunctions/strlwr.c b/Stringfunctions/strlwr.c new file mode 100644 index 0000000..72bd264 --- /dev/null +++ b/Stringfunctions/strlwr.c @@ -0,0 +1,8 @@ +#include +main() +{ + char c[20]; + printf("Enter the string:\n"); + gets(c); + printf("The string in lower case is: %s\n",strlwr(c)); +} diff --git a/Stringfunctions/strlwr.exe b/Stringfunctions/strlwr.exe new file mode 100644 index 0000000..7a9ac7e Binary files /dev/null and b/Stringfunctions/strlwr.exe differ diff --git a/Stringfunctions/strlwr.o b/Stringfunctions/strlwr.o new file mode 100644 index 0000000..9d5cb6d Binary files /dev/null and b/Stringfunctions/strlwr.o differ diff --git a/Stringfunctions/strrev.c b/Stringfunctions/strrev.c new file mode 100644 index 0000000..530c1be --- /dev/null +++ b/Stringfunctions/strrev.c @@ -0,0 +1,8 @@ +#include +main() +{ + char c[20]; + printf("Enter the string:\n"); + gets(c); + printf("The reverse is %s.",strrev(c)); +} diff --git a/Stringfunctions/strrev.exe b/Stringfunctions/strrev.exe new file mode 100644 index 0000000..0ffdb40 Binary files /dev/null and b/Stringfunctions/strrev.exe differ diff --git a/Stringfunctions/strrev.o b/Stringfunctions/strrev.o new file mode 100644 index 0000000..8e08d59 Binary files /dev/null and b/Stringfunctions/strrev.o differ diff --git a/Stringfunctions/strupr.c b/Stringfunctions/strupr.c new file mode 100644 index 0000000..8ee87a5 --- /dev/null +++ b/Stringfunctions/strupr.c @@ -0,0 +1,9 @@ +#include +main() +{ + char c[20]; + printf("Enter the string:\n"); + gets(c); + printf("The string in upper case is: %s\n",strupr(c)); +} + diff --git a/Stringfunctions/strupr.exe b/Stringfunctions/strupr.exe new file mode 100644 index 0000000..9d1871d Binary files /dev/null and b/Stringfunctions/strupr.exe differ diff --git a/Stringfunctions/strupr.o b/Stringfunctions/strupr.o new file mode 100644 index 0000000..e1a563a Binary files /dev/null and b/Stringfunctions/strupr.o differ diff --git a/stringwithoutfunctions/comparestring.c b/stringwithoutfunctions/comparestring.c new file mode 100644 index 0000000..d24ce8d --- /dev/null +++ b/stringwithoutfunctions/comparestring.c @@ -0,0 +1,30 @@ +#include +main() +{ + int i,flag=0,m,n; + char c[20],s[20]; + printf("Enter string 1:\n"); + gets(c); + printf("Enter string 2:\n"); + gets(s); + m=strlen(c); + n=strlen(s); + if(m==n) + { + for(i=0;s[i]!='\0';i++) + { + if(s[i]==c[i]) + { + flag=1; + } + else + { + break; + } + } + } + if(flag==0) + printf("The strings are not equal.\n"); + else + printf("The strings are equal.\n"); +} diff --git a/stringwithoutfunctions/comparestring.exe b/stringwithoutfunctions/comparestring.exe new file mode 100644 index 0000000..66b1d16 Binary files /dev/null and b/stringwithoutfunctions/comparestring.exe differ diff --git a/stringwithoutfunctions/comparestring.o b/stringwithoutfunctions/comparestring.o new file mode 100644 index 0000000..d358197 Binary files /dev/null and b/stringwithoutfunctions/comparestring.o differ diff --git a/stringwithoutfunctions/copystring.c b/stringwithoutfunctions/copystring.c new file mode 100644 index 0000000..8f1f755 --- /dev/null +++ b/stringwithoutfunctions/copystring.c @@ -0,0 +1,16 @@ +#include +main() +{ + int i; + char c[20],s[20]; + printf("Enter the string 1:\n"); + gets(c); + for(i=0;c[i]!='\0';i++) + { + s[i]=c[i]; + } + s[i]='\0'; + puts(s); + +} + diff --git a/stringwithoutfunctions/copystring.exe b/stringwithoutfunctions/copystring.exe new file mode 100644 index 0000000..c8065aa Binary files /dev/null and b/stringwithoutfunctions/copystring.exe differ diff --git a/stringwithoutfunctions/copystring.o b/stringwithoutfunctions/copystring.o new file mode 100644 index 0000000..ec4d881 Binary files /dev/null and b/stringwithoutfunctions/copystring.o differ diff --git a/stringwithoutfunctions/copystring2.c b/stringwithoutfunctions/copystring2.c new file mode 100644 index 0000000..7971046 --- /dev/null +++ b/stringwithoutfunctions/copystring2.c @@ -0,0 +1,21 @@ +#include +main() +{ + int i; + char c[20],s[20]; + printf("Enter the string 1:\n"); + gets(c); + for(i=0;c[i]!='\0';i++) + { + s[i]=c[i]; + } + s[i]='\0'; + for(i=0;s[i]!='\0';i++) //method1 + { + printf("%c",s[i]); + } + printf("\n"); + printf("%s\n",s); //method 2 + + puts(s); //method 3 +}