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 c-file/big2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>
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;
}
19 changes: 19 additions & 0 deletions c-file/fact.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
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;
}
7 changes: 7 additions & 0 deletions c-file/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include<stdio.h>
main() {

biggest();
factorial();
reverse();
}
12 changes: 12 additions & 0 deletions c-file/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ABC.exe:main.o big2.o fact.o rev.o
gcc -o ABC.exe main.o big2.o fact.o rev.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
clean:
rm -rf *.o
24 changes: 24 additions & 0 deletions c-file/rev.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
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);
}