From 878741c82ab11b788e3c456a924017e3cf13c8a4 Mon Sep 17 00:00:00 2001 From: yogeshmandal1 <65283651+yogeshmandal1@users.noreply.github.com> Date: Thu, 14 May 2020 14:31:06 +0530 Subject: [PATCH] assingment#2 --- ... string without using inbuilt function.cpp | 17 +++++++++ assingment#2/questin.1.c | 33 +++++++++++++++++ assingment#2/question .2.cpp | 35 +++++++++++++++++++ assingment#2/question .4.c | 21 +++++++++++ assingment#2/question .4.cpp | 20 +++++++++++ 5 files changed, 126 insertions(+) create mode 100644 assingment#2/q.5 copy the string without using inbuilt function.cpp create mode 100644 assingment#2/questin.1.c create mode 100644 assingment#2/question .2.cpp create mode 100644 assingment#2/question .4.c create mode 100644 assingment#2/question .4.cpp diff --git a/assingment#2/q.5 copy the string without using inbuilt function.cpp b/assingment#2/q.5 copy the string without using inbuilt function.cpp new file mode 100644 index 0000000..61026db --- /dev/null +++ b/assingment#2/q.5 copy the string without using inbuilt function.cpp @@ -0,0 +1,17 @@ +5) WAP to copy one string into other string(without using inbuild function strcpy() +ANS +#include +int main() { + char s1[100], s2[100], i; + printf("Enter string s1: "); + fgets(s1, sizeof(s1), stdin); + + for (i = 0; s1[i] != '\0'; ++i) { + s2[i] = s1[i]; + } + + s2[i] = '\0'; + printf("String s2: %s", s2); + return 0; +} + diff --git a/assingment#2/questin.1.c b/assingment#2/questin.1.c new file mode 100644 index 0000000..283ae25 --- /dev/null +++ b/assingment#2/questin.1.c @@ -0,0 +1,33 @@ +Q1 +#include +int main() +{ +int MAX_SIZE=100, arr[MAX_SIZE], size, i, toSearch, found ; +printf("Enter size of array: "); + scanf("%d", &size); + printf("Enter elements in array: "); + for(i=0; i +int main() +{ + int MAX_SIZE=100,arr[MAX_SIZE],size,i, j, k; + printf("Enter size of the array : "); + scanf("%d", &size); + printf("Enter elements in array : "); + for(i=0; i +int main() +{ + char s[1000]; + int i,n,c=0; + printf("Enter the string : "); + gets(s); + n=strlen(s); + for(i=0;i +int main() +{ +int a[10],n,i; +printf("Enter the number to convert: "); +scanf("%d",&n); +for(i=0;n>0;i++) +{ +a[i]=n%2; +n=n/2; +} +printf("\nBinary of Given Number is="); +for(i=i-1;i>=0;i--) +{ +printf("%d",a[i]); +} +return 0; +} +