commit 00c53c15d38ffdadccaeb0f0cd434cfac5257963
parent 9251fbe535b56ce020f8e12d2305a12778c2bf48
Author: Amit Dutta <amitdutta4255@gmail.com>
Date: Tue, 2 Sep 2025 21:52:10 +0530
Add files via upload
Diffstat:
4 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/practice-c/rev.c b/practice-c/rev.c
@@ -0,0 +1,25 @@
+//WAP to reverse a non-negative integer.
+
+#include<stdio.h>
+
+int main() {
+ int inp, result = 0, temp;
+ printf("PLease enter the number you want to reverse : ");
+ scanf("%d",&inp);
+ printf("\n");
+
+ if (inp < 0) {
+ printf("\nPlease enter a non negetive integer.");
+ return 0;
+ }
+
+ temp = inp;
+ while ( temp != 0) {
+ result = (result * 10) + (temp % 10);
+ temp = temp / 10;
+ }
+
+ printf("\nReverse of the input '%d' is : %d", inp, result);
+ return 0;
+}
+
diff --git a/practice-c/rev.exe b/practice-c/rev.exe
Binary files differ.
diff --git a/practice-c/s=1-2+3-4+5-6....c b/practice-c/s=1-2+3-4+5-6....c
@@ -0,0 +1,26 @@
+//WAP to compute the sum of the first n terms of the following series,S =1-2+3- 4+5…………
+
+#include<stdio.h>
+
+int main() {
+ int n, result = 0, temp, i;
+ printf("Please enter the value for 'n' for this series 's = 1-2+3-4+5-....': ");
+ scanf("%d",&n);
+ printf("\n");
+
+ if (n <= 0) {
+ printf("\nPlease enter a positive integer.");
+ return 0;
+ }
+
+ for (i = 1; i<= n; i++) {
+ if (i % 2 == 0) {
+ result = result - i;
+ }
+ else {
+ result = result + i;
+ }
+ }
+
+ printf("\nAns : %d", result);
+}
diff --git a/practice-c/s=1-2+3-4+5-6....exe b/practice-c/s=1-2+3-4+5-6....exe
Binary files differ.