diff --git a/Vridhi_Palindrome_q13.c b/Vridhi_Palindrome_q13.c new file mode 100644 index 0000000..58aca95 --- /dev/null +++ b/Vridhi_Palindrome_q13.c @@ -0,0 +1,17 @@ +#include +int main(){ + int n, reverse = 0,dig,original; + scanf("%d",&n); + original = n; + while(n>0){ + dig = n % 10; + reverse = (reverse * 10) + dig; + n = (int)(n / 10); + } + printf("%d\n",reverse); + if(original == reverse){ + printf("Palindrome"); + }else{ + printf("Not a Palindrome"); + } +} \ No newline at end of file diff --git a/Vridhi_Palindrome_q13.exe b/Vridhi_Palindrome_q13.exe new file mode 100644 index 0000000..d601047 Binary files /dev/null and b/Vridhi_Palindrome_q13.exe differ diff --git a/Vridhi_Palindrome_q13.py b/Vridhi_Palindrome_q13.py new file mode 100644 index 0000000..6feb71e --- /dev/null +++ b/Vridhi_Palindrome_q13.py @@ -0,0 +1,4 @@ +n = int(input("n:")) +m = str(n) +reverse = int(m[::-1]) +print("Palindrome") if n == reverse else print("Not a Palindrome") diff --git a/Vridhi_evenorodd_q2.c b/Vridhi_evenorodd_q2.c new file mode 100644 index 0000000..1cd43b8 --- /dev/null +++ b/Vridhi_evenorodd_q2.c @@ -0,0 +1,7 @@ +#include +int main(){ + int n; + scanf("%d",&n); + n % 2==0? printf("Even") : printf("Odd"); + return 0; +} \ No newline at end of file diff --git a/Vridhi_evenorodd_q2.exe b/Vridhi_evenorodd_q2.exe new file mode 100644 index 0000000..af41031 Binary files /dev/null and b/Vridhi_evenorodd_q2.exe differ diff --git a/Vridhi_evenorodd_q2.py b/Vridhi_evenorodd_q2.py new file mode 100644 index 0000000..906c9ab --- /dev/null +++ b/Vridhi_evenorodd_q2.py @@ -0,0 +1,3 @@ +n = int(input("enter to check whether n is odd or even: ")) +oddoreven = "Odd" if n%2 !=0 else "Even" +print(oddoreven) \ No newline at end of file diff --git a/Vridhi_greatestofthree_q7.c b/Vridhi_greatestofthree_q7.c new file mode 100644 index 0000000..c575e2b --- /dev/null +++ b/Vridhi_greatestofthree_q7.c @@ -0,0 +1,7 @@ +#include +int main(){ + int m ,n, o; + scanf("%d %d %d", &m,&n,&o); + (m > n) && (m > o)? printf("%d",m) : (n > o) && (n > m)? printf("%d",n) :printf("%d", o); + return 0; +} \ No newline at end of file diff --git a/Vridhi_greatestofthree_q7.exe b/Vridhi_greatestofthree_q7.exe new file mode 100644 index 0000000..fd57786 Binary files /dev/null and b/Vridhi_greatestofthree_q7.exe differ diff --git a/Vridhi_greatestofthree_q7.py b/Vridhi_greatestofthree_q7.py new file mode 100644 index 0000000..132525f --- /dev/null +++ b/Vridhi_greatestofthree_q7.py @@ -0,0 +1,9 @@ +n = int(input("First number : ")) +m = int(input("second number : ")) +o = int(input("third number : ")) +if (n > o) and (n > m): + print(n) +elif (m > o) and (m > n): + print(m) +else: + print(o) \ No newline at end of file diff --git a/Vridhi_greatestoftwo_q6.c b/Vridhi_greatestoftwo_q6.c new file mode 100644 index 0000000..9806739 --- /dev/null +++ b/Vridhi_greatestoftwo_q6.c @@ -0,0 +1,6 @@ +#include +int main(){ + int n,m; + scanf("%d %d",&n,&m); + n>m? printf("%d",n) : printf("%d",m); +} \ No newline at end of file diff --git a/Vridhi_greatestoftwo_q6.exe b/Vridhi_greatestoftwo_q6.exe new file mode 100644 index 0000000..662144f Binary files /dev/null and b/Vridhi_greatestoftwo_q6.exe differ diff --git a/Vridhi_greatestoftwo_q6.py b/Vridhi_greatestoftwo_q6.py new file mode 100644 index 0000000..8858fb0 --- /dev/null +++ b/Vridhi_greatestoftwo_q6.py @@ -0,0 +1,4 @@ +n = int(input("First number: ")) +m = int(input("Second number: ")) +greater = m if m > n else n +print(greater) \ No newline at end of file diff --git a/Vridhi_leapyear_q8.c b/Vridhi_leapyear_q8.c new file mode 100644 index 0000000..aed3dd3 --- /dev/null +++ b/Vridhi_leapyear_q8.c @@ -0,0 +1,16 @@ +#include +int main(){ + int year; + scanf("%d", &year); + if(year % 100==0){ + if(year%400 ==0){ + printf("%d is a leap year",year); + }else{ + printf("%d is a not a leap year",year); + } + }else if(year%4 == 0){ + printf("%d is a leap year", year); + }else{ + printf("%d is a not a leap year"); + } +} \ No newline at end of file diff --git a/Vridhi_leapyear_q8.exe b/Vridhi_leapyear_q8.exe new file mode 100644 index 0000000..8c07ba3 Binary files /dev/null and b/Vridhi_leapyear_q8.exe differ diff --git a/Vridhi_leapyear_q8.py b/Vridhi_leapyear_q8.py new file mode 100644 index 0000000..ef17b3a --- /dev/null +++ b/Vridhi_leapyear_q8.py @@ -0,0 +1,9 @@ +year = int(input("Write year to check: ")) +if year % 100 ==0: + if year % 400==0: + print(year, "is a leap year") + else: + print("Not a leap year") +else: + if year % 4 ==0: + print(year, "is a leap year") \ No newline at end of file diff --git a/Vridhi_positiveornegative_q1.c b/Vridhi_positiveornegative_q1.c new file mode 100644 index 0000000..5a04aba --- /dev/null +++ b/Vridhi_positiveornegative_q1.c @@ -0,0 +1,7 @@ +#include +int main(){ + int n; + scanf("%d",&n); + n >= 0? printf("Positive") : printf("Negative"); + return 0; +} \ No newline at end of file diff --git a/Vridhi_positiveornegative_q1.exe b/Vridhi_positiveornegative_q1.exe new file mode 100644 index 0000000..46109cc Binary files /dev/null and b/Vridhi_positiveornegative_q1.exe differ diff --git a/Vridhi_positiveornegative_q1.py b/Vridhi_positiveornegative_q1.py new file mode 100644 index 0000000..936389b --- /dev/null +++ b/Vridhi_positiveornegative_q1.py @@ -0,0 +1,3 @@ +n = int(input("Put number to check: ")) +result = "Positive" if n >=0 else "Negative" +print(result) \ No newline at end of file diff --git a/Vridhi_primeinrange_q10.c b/Vridhi_primeinrange_q10.c new file mode 100644 index 0000000..8b73fae --- /dev/null +++ b/Vridhi_primeinrange_q10.c @@ -0,0 +1,23 @@ +#include +int main(){ + int m,n; + scanf("%d %d",&m,&n); + for(int i = m ; i<=n ; i++ ){ + int flag = 0; + if (i<=1) + continue; + + for(int j = 2 ; j <= i ;j++){ + if(i % j == 0){ + flag = 1; + break; + } + + } + if(flag == 0){ + printf("%d",i); + } + } + +} + diff --git a/Vridhi_primeinrange_q10.exe b/Vridhi_primeinrange_q10.exe new file mode 100644 index 0000000..f2e2157 Binary files /dev/null and b/Vridhi_primeinrange_q10.exe differ diff --git a/Vridhi_primeinrange_q10.py b/Vridhi_primeinrange_q10.py new file mode 100644 index 0000000..3a36e79 --- /dev/null +++ b/Vridhi_primeinrange_q10.py @@ -0,0 +1,9 @@ +low = int(input("range starts from: ")) +high = int(input("range ends upto: ")) + +for i in range(low,high +1): + for j in range(2,i): + if i % j != 0: + print(i, end="") + break + \ No newline at end of file diff --git a/Vridhi_primeno_q9.c b/Vridhi_primeno_q9.c new file mode 100644 index 0000000..7e7dc6b --- /dev/null +++ b/Vridhi_primeno_q9.c @@ -0,0 +1,16 @@ +#include +int main(){ + int n,flag= 0; + scanf("%d",&n); + for(int i = 2;i <= n/2;i++){ + if(n%i==0){ + flag = 1; + break; + } + + }if((flag == 0) && (n > 1)){ + printf("%d is a prime",n); + }else{ + printf("%d is not a prime",n); + } +} \ No newline at end of file diff --git a/Vridhi_primeno_q9.exe b/Vridhi_primeno_q9.exe new file mode 100644 index 0000000..ec07c41 Binary files /dev/null and b/Vridhi_primeno_q9.exe differ diff --git a/Vridhi_primeno_q9.py b/Vridhi_primeno_q9.py new file mode 100644 index 0000000..3b09e57 --- /dev/null +++ b/Vridhi_primeno_q9.py @@ -0,0 +1,7 @@ +n = int(input("")) +for i in range(2,n): + if n % i == 0: + print("Not a prime") + break +else: + print("prime") \ No newline at end of file diff --git a/Vridhi_reverseofano_q12.c b/Vridhi_reverseofano_q12.c new file mode 100644 index 0000000..dd47be9 --- /dev/null +++ b/Vridhi_reverseofano_q12.c @@ -0,0 +1,9 @@ +#include +int main(){ + int n; + scanf("%d",&n); + while(n>0){ + printf("%d",n%10); + n = (int)(n / 10); + } +} \ No newline at end of file diff --git a/Vridhi_reverseofano_q12.exe b/Vridhi_reverseofano_q12.exe new file mode 100644 index 0000000..6418385 Binary files /dev/null and b/Vridhi_reverseofano_q12.exe differ diff --git a/Vridhi_reverseofano_q12.py b/Vridhi_reverseofano_q12.py new file mode 100644 index 0000000..fcd4f65 --- /dev/null +++ b/Vridhi_reverseofano_q12.py @@ -0,0 +1,4 @@ +n = int(input("n: ")) +m = str(n) +reverse = m[::-1] +print(reverse) diff --git a/Vridhi_sumofdigits_q11.c b/Vridhi_sumofdigits_q11.c new file mode 100644 index 0000000..343a364 --- /dev/null +++ b/Vridhi_sumofdigits_q11.c @@ -0,0 +1,18 @@ +#include +int main(){ + int n, sum = 0; + scanf("%d",&n); + if(n>=0){ + goto WHILE; + }else{ + n = -n; + goto WHILE; + } + + WHILE: + while(n>0){ + sum += n % 10; + n = (int)(n / 10); + } + printf("%d",sum); +} \ No newline at end of file diff --git a/Vridhi_sumofdigits_q11.exe b/Vridhi_sumofdigits_q11.exe new file mode 100644 index 0000000..42a09f8 Binary files /dev/null and b/Vridhi_sumofdigits_q11.exe differ diff --git a/Vridhi_sumofdigits_q11.py b/Vridhi_sumofdigits_q11.py new file mode 100644 index 0000000..650d078 --- /dev/null +++ b/Vridhi_sumofdigits_q11.py @@ -0,0 +1,14 @@ +n = int(input("n: ")) +def sumofdigits(m): + sum = 0 + while m > 0: + sum += m % 10 + m = m // 10 + return sum + +if n > 0: + sum2 = sumofdigits(n) +else: + n = -n + sum2 = sumofdigits(n) +print(sum2) diff --git a/Vridhi_sumoffirstnnatural_q4.c b/Vridhi_sumoffirstnnatural_q4.c new file mode 100644 index 0000000..f93bf3d --- /dev/null +++ b/Vridhi_sumoffirstnnatural_q4.c @@ -0,0 +1,14 @@ +#include +int main(){ + int n; + int sum = 0; + scanf("%d", &n); + if (n>=0){ + for(int i = 1; i <= n; i++ ){ + sum += i; + }} + else{ + printf("negative number not allowed."); + } + printf("sum = %d",sum); +} \ No newline at end of file diff --git a/Vridhi_sumoffirstnnatural_q4.exe b/Vridhi_sumoffirstnnatural_q4.exe new file mode 100644 index 0000000..4ee2d54 Binary files /dev/null and b/Vridhi_sumoffirstnnatural_q4.exe differ diff --git a/Vridhi_sumoffirstnnatural_q4.py b/Vridhi_sumoffirstnnatural_q4.py new file mode 100644 index 0000000..49220d1 --- /dev/null +++ b/Vridhi_sumoffirstnnatural_q4.py @@ -0,0 +1,2 @@ +n = int(input("n: ")) +print("sum: ",int((n*(n+1))*0.5)) \ No newline at end of file diff --git a/Vridhi_sumofninrange_q5.c b/Vridhi_sumofninrange_q5.c new file mode 100644 index 0000000..4725294 --- /dev/null +++ b/Vridhi_sumofninrange_q5.c @@ -0,0 +1,10 @@ +#include +int main(){ + int m, n; + scanf("%d %d",&m,&n); + int sum = 0; + for(int i = m; i<=n;i++){ + sum += i; + } + printf("%d",sum); +} \ No newline at end of file diff --git a/Vridhi_sumofninrange_q5.exe b/Vridhi_sumofninrange_q5.exe new file mode 100644 index 0000000..b95772d Binary files /dev/null and b/Vridhi_sumofninrange_q5.exe differ diff --git a/Vridhi_sumofninrange_q5.py b/Vridhi_sumofninrange_q5.py new file mode 100644 index 0000000..43d9fec --- /dev/null +++ b/Vridhi_sumofninrange_q5.py @@ -0,0 +1,7 @@ +#Sum of range +m = int(input("start from: ")) +n = int(input("end including: ")) +sum = 0 +for i in range(m,n+1,1): + sum = sum + i +print(sum) \ No newline at end of file diff --git a/Vridhi_sumofnnatural_q3.c b/Vridhi_sumofnnatural_q3.c new file mode 100644 index 0000000..f93bf3d --- /dev/null +++ b/Vridhi_sumofnnatural_q3.c @@ -0,0 +1,14 @@ +#include +int main(){ + int n; + int sum = 0; + scanf("%d", &n); + if (n>=0){ + for(int i = 1; i <= n; i++ ){ + sum += i; + }} + else{ + printf("negative number not allowed."); + } + printf("sum = %d",sum); +} \ No newline at end of file diff --git a/Vridhi_sumofnnatural_q3.exe b/Vridhi_sumofnnatural_q3.exe new file mode 100644 index 0000000..f5aafa2 Binary files /dev/null and b/Vridhi_sumofnnatural_q3.exe differ diff --git a/Vridhi_sumofnnatural_q3.py b/Vridhi_sumofnnatural_q3.py new file mode 100644 index 0000000..081dc31 --- /dev/null +++ b/Vridhi_sumofnnatural_q3.py @@ -0,0 +1,6 @@ +n = int(input("sum upto : ")) +sum = 0 +for i in range(0,n+1): + sum += i + +print("sum: ",sum) \ No newline at end of file