diff --git a/2nd_sem/Pull_Requests/Riya_Singh_DS_38/Problem1.c b/2nd_sem/Pull_Requests/Riya_Singh_DS_38/Problem1.c new file mode 100644 index 0000000..60fe8cb --- /dev/null +++ b/2nd_sem/Pull_Requests/Riya_Singh_DS_38/Problem1.c @@ -0,0 +1,22 @@ +#include + +int main() +{ + int n = 3 ; + + printf("Enter number : "); + scanf("%d",&n); + + printf("%d ",n); + + while(n != 1){ + if(n % 2 == 0){ + n = n/2; + } + else{ + n=3*n+1; + } + printf("%d ",n); + } + return 0; +} diff --git a/2nd_sem/Pull_Requests/Riya_Singh_DS_38/problem2.c b/2nd_sem/Pull_Requests/Riya_Singh_DS_38/problem2.c new file mode 100644 index 0000000..60fe8cb --- /dev/null +++ b/2nd_sem/Pull_Requests/Riya_Singh_DS_38/problem2.c @@ -0,0 +1,22 @@ +#include + +int main() +{ + int n = 3 ; + + printf("Enter number : "); + scanf("%d",&n); + + printf("%d ",n); + + while(n != 1){ + if(n % 2 == 0){ + n = n/2; + } + else{ + n=3*n+1; + } + printf("%d ",n); + } + return 0; +} diff --git a/2nd_sem/Pull_Requests/Riya_Singh_DS_38/problem3.c b/2nd_sem/Pull_Requests/Riya_Singh_DS_38/problem3.c new file mode 100644 index 0000000..b5e0fd0 --- /dev/null +++ b/2nd_sem/Pull_Requests/Riya_Singh_DS_38/problem3.c @@ -0,0 +1,35 @@ +#include + +int main() +{ + int n, t1, t2, x, y, movie = 1, endt; + + + printf("Enter the number of movies : "); + scanf("%d", &n); + + printf("Enter the starting time of the 1st movie : "); + scanf("%d", &t1); + + printf("Enter the ending time of the 1st movie : "); + scanf("%d", &t2); + endt=t2; + + for (int i = 1; i < n; i++) { + + printf("Enter starting time of the next movie : "); + scanf("%d",&x); + + printf("Enter the endig time of the next movie : "); + scanf("%d",&y); + + if (endt<=x) { + movie++; + endt = y; + } + } + + printf("Maximum number of movies that can be watched are : %d\n", movie); + + return 0; +}