Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added ABC.exe
Binary file not shown.
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ABC.exe: main.o big2.o fact.o rev.o pal.o big3.o sum2.o fibonaci.o sortnum.o
gcc -o ABC.exe main.o big2.o fact.o rev.o pal.o big3.o sum2.o fibonaci.o sortnum.o
main.o:main.c
gcc -c main.c
big2.o:big2.c
gcc -c big2.c
fact.o:fact.c
gcc -c fact.c
rev.o:rev.c
gcc -c rev.c
pal.o:pal.c
gcc -c pal.c
big3.o:big3.c
gcc -c big3.c
sum2.o:sum2.c
gcc -c sum2.c
fibonaci.o:fibonaci.c
gcc -c fibonaci.c
sortnum.o:sortnum.c
gcc -c sortnum.c
clean:
rm -rf *.o
22 changes: 22 additions & 0 deletions big2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>
void biggest()
{
int num1, num2;
// Ask user to enter the two numbers
printf("Please Enter Two different values\n");
// Read two numbers from the user
scanf("%d %d", &num1, &num2);
if(num1 > num2)
{
printf("%d is Largest\n", num1);
}
else if (num2 > num1)
{
printf("%d is Largest\n", num2);
}
else
{
printf("Both are Equal\n");
}
// return 0;
}
24 changes: 24 additions & 0 deletions big3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>

void biggest3()
{

double n1, n2, n3;

printf("\n\nEnter three different numbers: ");
scanf("%lf %lf %lf", &n1, &n2, &n3);

// if n1 is greater than both n2 and n3, n1 is the largest
if (n1 >= n2 && n1 >= n3)
printf("%.2f is the largest number.", n1);

// if n2 is greater than both n1 and n3, n2 is the largest
if (n2 >= n1 && n2 >= n3)
printf("%.2f is the largest number.", n2);

// if n3 is greater than both n1 and n2, n3 is the largest
if (n3 >= n1 && n3 >= n2)
printf("%.2f is the largest number.", n3);

//return 0;
}
19 changes: 19 additions & 0 deletions fact.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
void factorial() {
int n, i;
unsigned long long fact = 1;
printf("\nEnter an integer:");
scanf("%d", &n);

// shows error if the user enters a negative integer
if (n < 0)
printf("Error! Factorial of a negative number doesn't exist.");
else {
for (i = 1; i <= n; ++i) {
fact *= i;
}
printf("Factorial of %d = %llu", n, fact);
}

// return 0;
}
28 changes: 28 additions & 0 deletions fibonaci.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdio.h>
void fibonacci() {

int i, n;

// initialize first and second terms
int t1 = 0, t2 = 1;

// initialize the next term (3rd term)
int nextTerm = t1 + t2;

// get no. of terms from user
printf("\n\nEnter the number of terms: ");
scanf("%d", &n);

// print the first two terms t1 and t2
printf("Fibonacci Series: %d, %d, ", t1, t2);

// print 3rd to nth terms
for (i = 3; i <= n; ++i) {
printf("%d, ", nextTerm);
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
}

// return 0;
}
12 changes: 12 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdio.h>
main()
{
biggest();
factorial();
reverse();
palindrome();
biggest3();
sumof2();
fibonacci();
sortingnum();
}
1 change: 1 addition & 0 deletions makefile-cproject
Submodule makefile-cproject added at 70d44d
19 changes: 19 additions & 0 deletions pal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include<stdio.h>
void palindrome()
{
int n,r,sum=0,temp;
printf("\n\nEnter the number=");
scanf("%d",&n);
temp=n;
while(n>0)
{
r=n%10;
sum=(sum*10)+r;
n=n/10;
}
if(temp==sum)
printf("palindrome number ");
else
printf("not palindrome");
//return 0;
}
24 changes: 24 additions & 0 deletions rev.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
void reverse()
{
char str[1000], rev[1000];
int i, j, count = 0;
printf("\n\nEnter string to reverse:");
scanf("%s", str);
printf("\nString Before Reverse: %s", str);
//finding the length of the string
while (str[count] != '\0')
{
count++;
}
j = count - 1;

//reversing the string by swapping
for (i = 0; i < count; i++)
{
rev[i] = str[j];
j--;
}

printf("\nString After Reverse: %s\n", rev);
}
36 changes: 36 additions & 0 deletions sortnum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <stdio.h>
void sortingnum()
{

int i, j, a, n, number[30];
printf("\n\nEnter the value of N: \n");
scanf("%d", &n);

printf("Enter the numbers: \n");
for (i = 0; i < n; ++i)
scanf("%d", &number[i]);

for (i = 0; i < n; ++i)
{

for (j = i + 1; j < n; ++j)
{

if (number[i] > number[j])
{

a = number[i];
number[i] = number[j];
number[j] = a;

}

}

}

printf("The numbers arranged in ascending order are given below \n");
for (i = 0; i < n; ++i)
printf("%d\n", number[i]);

}
14 changes: 14 additions & 0 deletions sum2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdio.h>
void sumof2() {

int number1, number2, sum;

printf("\n\nEnter two integers: ");
scanf("%d %d", &number1, &number2);

// calculate the sum
sum = number1 + number2;

printf("%d + %d = %d", number1, number2, sum);
// return 0;
}