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
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.0 fact.o palindrome.o rev.o add2.o fibonacci.o sortnum.o big3.o
gcc -o ABC.exe main.o big2.o fact.o palindrome.o rev.o add2.o fibonacci.o sortnum.o big3.o
main.o:main.c
gcc -c main.c
big2.0:big2.c
gcc -c big2.c
fact.o:fact.c
gcc -c fact.c
palindrome.o:palindrome.c
gcc -c palindrome.c
rev.o:rev.c
gcc -c rev.c
add2.o:add2.c
gcc -c add2.c
fibonacci.o:fibonacci.c
gcc -c fibonacci.c
sortnum.o:sortnum.c
gcc -c sortnum.c
big3.o:big3.c
gcc -c big3.c
clean:
rm -rf *.o ABC.exe
18 changes: 18 additions & 0 deletions add2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdio.h>

void add2numbers() {
int num1, num2, sum;

printf("Enter the first number: ");
scanf("%d", &num1);

printf("Enter the second number: ");
scanf("%d", &num2);

sum = num1 + num2;

printf("The sum of %d and %d is %d\n", num1, num2, sum);

// return 0;
}

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;
}
27 changes: 27 additions & 0 deletions big3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdio.h>

void biggest3() {
int num1, num2, num3;

printf("Enter the first number: ");
scanf("%d", &num1);

printf("Enter the second number: ");
scanf("%d", &num2);

printf("Enter the third number: ");
scanf("%d", &num3);

if (num1 >= num2 && num1 >= num3) {
printf("%d is the biggest number\n", num1);
}
else if (num2 >= num1 && num2 >= num3) {
printf("%d is the biggest number\n", num2);
}
else {
printf("%d is the biggest number\n", num3);
}

//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("Enter 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;
}
21 changes: 21 additions & 0 deletions fibonacci.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>

void fibonacci() {
int n, i;
unsigned long long fib1 = 0, fib2 = 1, fib;

printf("Enter the number of terms: ");
scanf("%d", &n);

printf("Fibonacci Sequence: ");

for (i = 1; i <= n; ++i) {
printf("%llu, ", fib1);
fib = fib1 + fib2;
fib1 = fib2;
fib2 = fib;
}

//return 0;
}

14 changes: 14 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<stdio.h>
#include<string.h>

main() {
biggest();
factorial();
palindrome();
reverse();
fibonacci();
add2numbers();
sortnum();
biggest3();
}

19 changes: 19 additions & 0 deletions palindrome.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include<stdio.h>
#include<string.h>
void palindrome()
{
char a[5];
int i,n,t=0;
printf("enter the string \n");
scanf("%s",a);
for(i=0;i<strlen(a);i++)
{
if(a[i]==a[strlen(a)-i-1])
t=1;
}
if(t==1)
printf("its palindrome\n");
else
printf("its not\n");
// 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("\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", 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 sortnum() {
int num1, num2, num3, temp;

printf("Enter the first number: ");
scanf("%d", &num1);

printf("Enter the second number: ");
scanf("%d", &num2);

printf("Enter the third number: ");
scanf("%d", &num3);

// Sort the numbers in ascending order
if (num1 > num2) {
temp = num1;
num1 = num2;
num2 = temp;
}
if (num2 > num3) {
temp = num2;
num2 = num3;
num3 = temp;
}
if (num1 > num2) {
temp = num1;
num1 = num2;
num2 = temp;
}

printf("The numbers in ascending order: %d, %d, %d\n", num1, num2, num3);

//return 0;
}