Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
19a5826
Create Positive_Negetive_number
suvaniwaghmare085-droid Mar 27, 2026
de1e2cf
Update Positive_Negetive_number
suvaniwaghmare085-droid Mar 27, 2026
24f1364
Rename Positive_Negetive_number to Positive_Negetive_number.c
suvaniwaghmare085-droid Mar 27, 2026
d64e96e
Update Positive_Negetive_number.c
suvaniwaghmare085-droid Mar 27, 2026
ffd42c2
Create Even_odd_number.c
suvaniwaghmare085-droid Mar 27, 2026
0b5e902
Add program to calculate sum of first n natural numbers
suvaniwaghmare085-droid Apr 1, 2026
65b517e
Add C program for summing numbers in a range
suvaniwaghmare085-droid Apr 1, 2026
c6eac3e
Add C program to find the greatest of two numbers
suvaniwaghmare085-droid Apr 1, 2026
a2d8869
Add C program to find the greatest of three numbers
suvaniwaghmare085-droid Apr 1, 2026
f32e931
Create Leap year or not.c
suvaniwaghmare085-droid Apr 1, 2026
fd813f1
Create Prime number.c
suvaniwaghmare085-droid Apr 1, 2026
09c6efe
Create Prime number within a given range.c
suvaniwaghmare085-droid Apr 1, 2026
6600b62
Add C program to calculate sum of digits
suvaniwaghmare085-droid Apr 1, 2026
97878ca
Add program to reverse a number in C
suvaniwaghmare085-droid Apr 1, 2026
c3fe46c
Create Palindrome number.c
suvaniwaghmare085-droid Apr 1, 2026
57fdc45
Rename Even_odd_number.c to Suvani_Even_odd_number.c
suvaniwaghmare085-droid Apr 17, 2026
8af7661
Rename Greatest of 3 numbers.c to Suvani_Greatest of 3 numbers.c
suvaniwaghmare085-droid Apr 17, 2026
916f372
Rename sum of number in range.c to Suvani_sum of number in range.c
suvaniwaghmare085-droid Apr 17, 2026
0e3ce79
Add Suvani_greatest_of_two_numbers.c file
suvaniwaghmare085-droid Apr 17, 2026
e8c88a8
Rename Reverse of a number.c to Suvani.Reverse of a number.c
suvaniwaghmare085-droid Apr 27, 2026
29d6b1d
Rename Leap year or not.c to Suvani.Leap year or not.c
suvaniwaghmare085-droid Apr 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Palindrome number.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//Palindrome Number in C


// C code:

#include<stdio.h>

// Recursive way to find reverse of a number
int getReverse(int num, int rev){
if(num == 0)
return rev;

int rem = num % 10;
rev = rev * 10 + rem;

return getReverse(num / 10, rev);
}

int main ()
{
int num, reverse = 0;
num=12321;
printf("The number is: %d\n",num);

// palindrome if num and reverse are equal
if (num == getReverse(num, reverse))
printf("%d is Palindrome\n", num);
else
printf("%d is Not Palindrome\n", num);

}
22 changes: 22 additions & 0 deletions Positive_Negetive_number.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//Check if a Number is Positive or Negative in C
//Given an integer input, the objective is check whether the given integer is Positive or Negative


//C Code:

#include <stdio.h>
int main()
{
int num = 23;

//Conditions to check if the number is negative/positive or zero
if (num > 0)
printf("The number is positive");
else if (num < 0)
printf("The number is negative");
else
printf("Zero");

return 0;
}

48 changes: 48 additions & 0 deletions Prime number within a given range.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*Prime Numbers in a Given Range in C
A number that is divisible only by itself and 1 (e.g. 2, 3, 5, 7, 11).

The C program reduces the number of iterations within the loop. It is made to identify or calculate the prime numbers within a given range of numbers inserted by the user.

Ex:- if the user enters a range as 40 – 50

In that range 41, 43, 47, these three number are prime number.*/

// C code:
#include <stdio.h>

int checkPrime(int num)
{
// 0, 1 and negative numbers are not prime
if(num < 2){
return 0;
}
else{
// no need to run loop till num-1 as for any number x the numbers in
// the range(num/2 + 1, num) won't be divisible anyways.
// Example 36 wont be divisible by anything b/w 19-35
int x = num/2;
for(int i = 2; i < x; i++)
{
if(num % i == 0)
{
return 0;
}
}
}
// the number would be prime if we reach here
return 1;
}
int main()
{
int a=10, b=20;


for(int i=a; i <= b; i++){
if(checkPrime(i))
printf("%d ",i);
}

return 0;
}
//Time Complexity: O(N^2)
//Space Complexity O(1)
33 changes: 33 additions & 0 deletions Prime number.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*Check Whether a Number is Prime Number or Not in C
Given an integer input, the objective is to check whether or not the input integer is a prime or not.
In order to do so we check if the number is divisible by 2, if so it’s not a prime.
We also divide the numbers with the input until square root of the input, if any of them divides the number perfectly, it’s not a prime.
Here are some of the methods to Check Whether a Number is Prime or Not in C*/

// C code:

#include < stdio.h>

int main()
{
int i, count = 0;
int num = 19;

// checking number of divisors b/w 1 & num
for(i = 1; i <= num; i++) {
if(num % i == 0)
count += 1;
}
// 0 & 1 are not prime number
if(num == 0 || num == 1)
printf("%d is not prime", num);
//if number of divisors are > 2 then not prime else prime
else if(count > 2)
printf("%d is not prime", num);
else
printf("%d is prime", num);

return 0;
}
// Time complexity O(N)
// Space complexity O(1)
32 changes: 32 additions & 0 deletions Sum of digits of a number.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*In this C program, we will code Sum of Digits of a Number in C we will allow the user to enter any number and then we will divide the number into individual digits and add those individuals (sum=sum+digit) digits using While Loop.

Ex:- number is 231456

2 + 3 + 1 + 4 + 5 + 6 = 21

Sum of digit of a given number is 21*/

// C code:
#include<stdio.h>

int main ()
{
int num, sum = 0;

num = 1234;
printf("The number is = %d\n",num);

//loop to find sum of digits
while(num!=0){
sum += num % 10;
num = num / 10;
}

//output
printf("Sum: %d\n",sum);

return 0;

}
// Time complexity : O(N)
// Space complexity : O(1)
31 changes: 31 additions & 0 deletions Sum of first n natural numbers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//Sum of First N Natural Numbers in C
//In this article, we will see C Program to Find the Sum of First N Natural Numbers. A Natural number is the same as a Counting number. They are used to Count the number of real physical objects. Natural numbers start from 1 and go on infinite.

//The positive numbers 1,2,3 ... are known as natural numbers.


//Formula for Sum of First n natural numbers is : n(n+1)/2.
//If you want to add first 5 Natural number
//then we find the Sum of 1+2+3+4+5 =15.

// C code:
#include <stdio.h>

int main()
{
int n;
scanf("%d",&n);

int sum = 0;

for(int i=1;i<=n;i++)
// is same as writing sum = sum + i
sum += i;

printf("Sum is %d",sum);

return 0;
}

// Time complexity : O(n)
// Space complexity : O(1)
25 changes: 25 additions & 0 deletions Suvani.Leap year or not.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//Check if the Year is a Leap Year or Not in C
//Given an integer input for the year, the objective is to check if the given year input is a leap year or not. To do so we check whether the year is divisible by 400 or not, if true then it’s a leap year, it’s not a leap year otherwise. Therefore we write a program to Check if the Year in a Leap Year or Not in C.

//Example
//Input : 2020
//Output : It's a Leap Year

// C code:
#include <stdio.h>
int main ()
{
int year;
year=2000;

if(year % 400 == 0)
printf("%d is a Leap Year",year);

else if(year % 4 == 0 && year % 100 != 0)
printf("%d is a Leap Year",year);

else
printf("%d is not a Leap Year",year);

return 0;
}
27 changes: 27 additions & 0 deletions Suvani.Reverse of a number.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//Program to Reverse a Number in C

// C code:
#include<stdio.h>

//main program
int main ()
{
//variables initialization
int num, reverse = 0, rem;
num=1234;
printf("The number is: %d\n",num);


//loop to find reverse number
while(num != 0)
{
rem = num % 10;
reverse = reverse * 10 + rem;
num /= 10;
};

//output
printf("Reverse: %d\n",reverse);

return 0;
}
42 changes: 42 additions & 0 deletions Suvani_Even_odd_number.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//The number is Even or Odd Program in C
//We can determine whether a number is Even or Odd program in C. This can be tested using different methods. The test can be done using simple methods such as
// Testing the number’s divisibility by 2.
// If the remainder is zero, the number is even.
// If the remainder is not zero, then the number is odd.

//C code:

//Method 1:

#include <stdio.h>

int main ()
{
int number;
printf ("Insert a number \n");
scanf ("%d", &number);

//Checking if the number is divisible by 2
if (number % 2 == 0)
printf ("Even");
else
printf ("Odd");

return 0;
}

// Method 2:

#include <stdio.h>
int main ()
{
int number;
printf ("Insert a number \n");
scanf ("%d", &number);

//Checking if the number is divisible by 2
number % 2 == 0? printf ("Even"):printf ("Odd");

return 0;
}

33 changes: 33 additions & 0 deletions Suvani_Greatest of 3 numbers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//Find the Greatest of Three Numbers in C
//Given three integers num1, num2 and num3 as inputs. The objective is to write a code to Find the Greatest of the Three Numbers in C Language. To do so we’ll check the numbers with each other and print the largest of them all.

//Example
//Input : num1 = 2 num2 = 9 num3 = 4
//Output : 9




// C code:

#include <stdio.h>
int main ()
{
int num1, num2, num3;

num1=12,num2=17,num3=19;

//checking if num1 is greatest
if (num1 >= num2 && num1 >= num3)
printf("%d is the greatest", num1);

//checking if num2 is greatest
else if(num2 >= num1 && num2 >= num3)
printf("%d is the greatest", num2);

//checking if num2 is greatest
else if(num3 >= num1 && num3 >= num2)
printf("%d is the greatest", num3);

return 0;
}
24 changes: 24 additions & 0 deletions Suvani_greatest_of_two_numbers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//Find the Greatest of the two numbers in C
//Given two integer inputs num1 and num2, the objective if to write a code to Find the Greatest of the Two Numbers in C.

//Example
//Input : num1 = 5 and num2 = 6
//Output : 6

//C code:
#include<stdio.h>

int main ()
{
int num1, num2;
num1=12,num2=13;

if (num1 == num2)
printf("both are equal");
else if (num1 > num2)
printf("%d is greater", num1);
else
printf("%d is greater", num2);

return 0;
}
28 changes: 28 additions & 0 deletions Suvani_sum of number in range.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//Find the Sum of Numbers in a Given Range in C
//Given two integer inputs num1 and num2, the objective is to write a code to Find the Sum of Numbers in a Given Range in C. To do so we’ll keep iterating and adding the numbers from num1 until num2 to the Sum variable.

//Example
//Input : 2 4
//Output : 2 + 3 + 4 = 9



// C code
#include <stdio.h>

int main()
{
int a = 5;
int b = 10;

int sum = 0;

for (int i = a; i <= b; i++)
sum = sum + i;

printf("%d",sum);

return 0;
}
// Time complexity : O(N)
// Space complexity : O(1)