Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X pattern print #283

Open
wants to merge 184 commits into
base: revert-61-PrimalityTest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
0eed935
Added the file Finding Factorial of an Integer.c
Manaarth Oct 6, 2019
3379be3
Added the file Palindrome.c
Manaarth Oct 6, 2019
32ddab3
Added solution
ayanujju Oct 6, 2019
a13315a
Added Swapping(without using extra variable).cpp
sarveshsrv Oct 7, 2019
2f110ea
Added LenghtOfString(without using strlen).cpp
sarveshsrv Oct 7, 2019
104040a
Merge pull request #70 from gouravthakur39/revert-61-PrimalityTest
gouravthakur39 Oct 7, 2019
673b44b
Anagram-Program-in-C
skcshubham Oct 7, 2019
d6b9785
checkAnagram.c
skcshubham Oct 7, 2019
c7be60d
Merge pull request #71 from skcshubham/patch-1
gouravthakur39 Oct 7, 2019
cd3b426
Added endian.c which identifies machine is Little/Big Endian
sudhakar-mnsr Oct 7, 2019
bfaace9
Updated
ayanujju Oct 7, 2019
f0f25d1
Merge pull request #72 from sudhakar-mnsr/master
gouravthakur39 Oct 7, 2019
804ea06
Update README.md
gouravthakur39 Oct 7, 2019
0814062
Updated
ayanujju Oct 7, 2019
4bb5d8e
Merge pull request #67 from ayanujju/patch-1
gouravthakur39 Oct 7, 2019
ce7b8a0
Added Perfect Number.cpp
sarveshsrv Oct 7, 2019
b7ec818
Add lcm calculator
Oct 7, 2019
2efe70f
Added a Cprogram changing the base of a no.
Pulgit555 Oct 7, 2019
ef225f8
Added a new Cprogram to change base of a no.
Pulgit555 Oct 7, 2019
271f246
Added PerfectNumber.c
sarveshsrv Oct 7, 2019
cd44f88
Delete PerfectNumber.c
sarveshsrv Oct 7, 2019
1ead06d
Merge pull request #74 from venkat-abhi/add-lcm
gouravthakur39 Oct 7, 2019
4e36b5e
Added Perfect Num.c
sarveshsrv Oct 7, 2019
8384cae
Resolved the conflict
Pulgit555 Oct 7, 2019
57c70cc
add gcd
Oct 7, 2019
e904554
Deleted the extra file
Pulgit555 Oct 7, 2019
d29d92c
add calculator for last digit of nth fibonacci number
Oct 7, 2019
99503c8
added a file for multiplication by Russian Peasant Algorithm
Architjain128 Oct 7, 2019
8263727
Merge pull request #79 from Architjain128/multiplication
gouravthakur39 Oct 8, 2019
1071da1
Merge pull request #77 from venkat-abhi/add-last-fib
gouravthakur39 Oct 8, 2019
0a60235
Merge pull request #76 from venkat-abhi/add-gcd
gouravthakur39 Oct 8, 2019
4708c73
Add counting sort
Oct 8, 2019
65dcf2a
added a pattern for pascal triangle
Architjain128 Oct 8, 2019
82a2e5d
Added a Cprogram to print the no. pattern
Pulgit555 Oct 8, 2019
3f81439
heap sort in c
Ananyan25 Oct 8, 2019
503aeb6
fixed the issue
Ananyan25 Oct 8, 2019
8ff007e
Merge pull request #82 from Ananyan25/master
gouravthakur39 Oct 8, 2019
51bbbec
Basic_Examples
aman-khandelwal-28 Oct 8, 2019
65a0588
Updated Code
dcjc29 Oct 9, 2019
4769050
Added transpose Of Matrix.c
sarveshsrv Oct 10, 2019
c8f5123
Automorphic Number
FalguniAjmera Oct 10, 2019
3bf7699
Even Fibonacci Number
Sudeep25022000 Oct 11, 2019
5ece803
Make the code strictly conforming to ISO C
adeishs Oct 11, 2019
33096c6
Merge pull request #89 from adeishs/Pointers/iso-conforming
gouravthakur39 Oct 11, 2019
615f652
Merge pull request #88 from Sudeep25022000/master
gouravthakur39 Oct 11, 2019
fc2b2fc
Merge pull request #87 from FalguniAjmera/master
gouravthakur39 Oct 11, 2019
c13e399
Merge pull request #83 from aman-2k18/master
gouravthakur39 Oct 11, 2019
7b14741
Merge pull request #81 from Architjain128/pascal
gouravthakur39 Oct 11, 2019
544dc5c
Merge pull request #80 from venkat-abhi/add-counting-sort
gouravthakur39 Oct 11, 2019
1049b93
Merge pull request #75 from Pulkit555/Cprogram
gouravthakur39 Oct 11, 2019
efa4f47
Merge pull request #73 from sarveshsrv/master
gouravthakur39 Oct 11, 2019
43960d5
Resolved Conflicts
Manaarth Oct 11, 2019
dcc88d4
Merge pull request #65 from Manaarth/wip
gouravthakur39 Oct 11, 2019
f7c29c7
Create Linked List Creation
bharatchhipa Oct 11, 2019
69f2754
Merge pull request #1 from bharatchhipa/bharatchhipa-patch-1
bharatchhipa Oct 11, 2019
1b20b43
Create Binary to decimal
bharatchhipa Oct 11, 2019
d7ccf40
Merge pull request #2 from bharatchhipa/bharatchhipa-patch-2
bharatchhipa Oct 11, 2019
45e49c7
Create Decimal to Binary
bharatchhipa Oct 11, 2019
baecc46
Merge pull request #3 from bharatchhipa/bharatchhipa-patch-3
bharatchhipa Oct 11, 2019
2acac9e
Create Address of 1-D array
bharatchhipa Oct 11, 2019
b39cc32
Merge pull request #92 from bharatchhipa/bharatchhipa-patch-4
gouravthakur39 Oct 12, 2019
24999f9
Create SelectionSort.c
TVSSSRIPAD Oct 12, 2019
870b7cd
Update SelectionSort.c
TVSSSRIPAD Oct 12, 2019
489398e
Update SelectionSort.c
TVSSSRIPAD Oct 12, 2019
2869488
Corrected a typo in readme.md
TVSSSRIPAD Oct 12, 2019
624b522
Merge pull request #94 from TVSSSRIPAD/master
gouravthakur39 Oct 12, 2019
c00e47c
Added MagicNumbers.c
TVSSSRIPAD Oct 12, 2019
0bd7282
Added a program for temperature switch using c algorithm
chaudhary1337 Oct 12, 2019
c5f3354
Implementation of Priority Queue using Max Heap Using C Programming L…
rishitc Oct 12, 2019
d71a202
New pattern added
Sudeep25022000 Oct 13, 2019
91e7cc8
Modified Addition.c
santhoshganesh13 Oct 13, 2019
31526ac
Patterns and it's Algorithm
Sudeep25022000 Oct 13, 2019
4501d1d
added code to calculate upto 5000!
VedanshM Oct 13, 2019
a44df32
fixed a typo in code large_factorial and made it more interactive
VedanshM Oct 13, 2019
77e573f
Merge pull request #102 from Ved246/large_factorial
gouravthakur39 Oct 13, 2019
e4d96b6
First and Second max element in an array
Sudeep25022000 Oct 13, 2019
393df77
Create Position_of_First'n'Second_max_elements_without_sorting_array
Sudeep25022000 Oct 13, 2019
59b57d9
Create SimpleArithmeticAverage
jpedroxd Oct 13, 2019
f30407e
Prints Basic Star Pattern
utkars-h Oct 13, 2019
6149dab
Added few more programs to the readme.md list
rishitc Oct 14, 2019
729f415
Added New File: increment_number.c
Oct 14, 2019
bc09c57
add an example of malloc()
tripoloski1337 Oct 15, 2019
8d3b2ce
Merge pull request #110 from tripoloski1337/master
gouravthakur39 Oct 15, 2019
1aa2a04
Merge pull request #109 from Dan-Kode/master
gouravthakur39 Oct 15, 2019
2cf5d66
Merge pull request #107 from utkars-h/master
gouravthakur39 Oct 15, 2019
2ebdc43
Merge pull request #106 from jpedrinhoxd/patch-1
gouravthakur39 Oct 15, 2019
dea5aa0
Merge pull request #99 from Sudeep25022000/master
gouravthakur39 Oct 15, 2019
1d2d84c
Merge pull request #98 from santhoshganesh13/master
gouravthakur39 Oct 15, 2019
287a506
Merge pull request #97 from rishitc/master
gouravthakur39 Oct 15, 2019
06dc9e6
Merge pull request #96 from SmartyPants042/master
gouravthakur39 Oct 15, 2019
9006997
Merge pull request #95 from TVSSSRIPAD/master
gouravthakur39 Oct 15, 2019
f1fdc08
Merge pull request #84 from dcjc29/master
gouravthakur39 Oct 15, 2019
73ff154
Update README.md
ParikhAditya Oct 15, 2019
cdcaad3
Fibonnaci Series
OmangRawat Oct 16, 2019
9b4296c
Added Program to Calculate nCr of Large Numbers Using Modular Arithmetic
chaudhary1337 Oct 16, 2019
a56b839
Merge pull request #113 from SmartyPants042/master
gouravthakur39 Oct 16, 2019
9715208
calculate and print the volume and surface area of ​​a straight cone,…
leofls Oct 17, 2019
9b78502
Added prorgam to Calculate Modular Inverse
chaudhary1337 Oct 17, 2019
112c9c3
Added Program to calculate Modular Exponents Quickly
chaudhary1337 Oct 17, 2019
67a360a
Add Number_to_Chacarter Program
HelioAdson Oct 18, 2019
70738aa
Create pattern.c
manan012 Oct 21, 2019
e428766
ARRAY IMPLEMENTATION
CO18325 Oct 25, 2019
21717a0
Add linear congruential PRNG example program
pjpollina Oct 25, 2019
6425cc2
Create linked_list.c
shivangahuja24 Oct 26, 2019
216bf9c
Create FIND_EVEN_ AND_DIVISIBLE_BY_3.c
shivangahuja24 Oct 26, 2019
563ca74
kth smallest no in an array.c
himanshusharma89 Oct 26, 2019
764a351
Convert an array to reduced form.c
himanshusharma89 Oct 26, 2019
fc4b9a5
LinkedLists program
Venkatavaradan-R Oct 27, 2019
b409b60
Adding fractions algorithm
Dvogiatz Oct 27, 2019
47916df
Added C program to find the closest power of 2 for a number
jindalabhishek1 Oct 31, 2019
1ee7311
Merge pull request #111 from obiwan69/master
gouravthakur39 Feb 26, 2020
303a47c
Finding the first missing natural number
sg7801 May 12, 2020
3732f76
Calculate Simple Interest
shreyanshthakur May 15, 2020
c856d84
Update BasicArithmatic.c
goelhr Jul 2, 2020
06f5ecb
Merge pull request #151 from goelhr/patch-2
gouravthakur39 Jul 2, 2020
188a4c7
Create Linked_List.c
Ritika-Das Jul 25, 2020
9ace8f5
Create Number_guessing_game
sonucodes Sep 20, 2020
9985816
Create camelcase
DeepanshAgrawal Sep 27, 2020
7e45365
Slicestring
Shrutijain005 Oct 1, 2020
5393c3c
Create MostFrequentWordInString.c
nivanjanapramod Oct 1, 2020
2a049ef
Add files via upload
itzNikhilll Oct 1, 2020
5e926bb
Create binary_to_octal.c
sonal10red100 Oct 2, 2020
86fc2b6
Create StringReverse.c
PranjalBagal Oct 2, 2020
0d07504
Update Address of 1-D array
tyadav4268 Oct 4, 2020
0e297f8
Create stack_using_linklist
spyic Oct 4, 2020
0cef526
Create check functon is even or odd in c programming
Mansi-1120 Oct 6, 2020
ad3bfae
Create to find average & sum of a,b,c in one function
Mansi-1120 Oct 6, 2020
ee365ce
Create sparse_matrix.c
Rochisha24 Oct 8, 2020
2345c3f
Update and rename sparse_matrix.c to SpiralMatrix.c
Rochisha24 Oct 8, 2020
1dd0042
add lambda examples by compiler extension
swt02026 Oct 9, 2020
0cabe20
Log_conversion
adarsh1mehra Oct 28, 2020
f6383ff
Linked list file added
anishtilak16 Dec 19, 2020
2e2a9e7
linked list file added
anishtilak16 Dec 19, 2020
d3f4015
Update Polynomial_linklist.c
lazy-dude Jan 30, 2021
831b639
updated gcd.c file with better functionality
thetejasmagade May 17, 2021
09bc281
Create ip_address.c
thetejasmagade May 17, 2021
c480652
added a beautiful code for lexicographic sorting
nipun-das Oct 1, 2021
a1a06dd
added a program to get all PIDs that is used by parent and child in a…
jeremie1112 Oct 3, 2021
fe60661
Create Binary-Tree-Traversals
nishantagrawal01 Oct 30, 2021
171c0b3
Add files via upload
implosion07 Jan 8, 2022
7966b23
program to multiply two numbers
implosion07 Jan 8, 2022
96f8596
Linear search program
implosion07 Jan 8, 2022
3f53d5d
Program to check if a number is c or not
implosion07 Jan 8, 2022
0f9c054
Merge pull request #112 from OmangRawat/master
gouravthakur39 Jun 21, 2022
66b4392
Merge pull request #114 from leofls/print-area-vol-cone-sphere
gouravthakur39 Jun 21, 2022
2b6966d
Merge pull request #115 from chaudhary1337/master
gouravthakur39 Jun 21, 2022
a5c9731
Merge pull request #117 from HelioAdson/Add-Number-to-Character
gouravthakur39 Jun 21, 2022
8b40629
Merge pull request #120 from manan012/master
gouravthakur39 Jun 21, 2022
6c4374a
Merge pull request #123 from CO18325/master
gouravthakur39 Jun 21, 2022
dd0d496
Merge pull request #124 from pjpollina/master
gouravthakur39 Jun 21, 2022
641a30e
Merge pull request #125 from shivang2k/master
gouravthakur39 Jun 21, 2022
45b09ea
Merge pull request #127 from himanshusharma89/master
gouravthakur39 Jun 21, 2022
d55a706
Merge pull request #129 from Venkatavaradan-R/master
gouravthakur39 Jun 21, 2022
35b7131
Merge pull request #130 from Dvogiatz/master
gouravthakur39 Jun 21, 2022
0ae5e7f
Merge pull request #261 from implosion07/master
gouravthakur39 Jun 25, 2022
f06964e
Merge pull request #259 from nishantagrawal01/master
gouravthakur39 Jun 25, 2022
1caf628
Merge pull request #258 from jeremie1112/master
gouravthakur39 Jun 25, 2022
19660e8
Merge pull request #257 from nipun-das/Nipun-Das-patch-1
gouravthakur39 Jun 25, 2022
6f6c9c7
Merge pull request #248 from thetejasmagade/patch-2
gouravthakur39 Jun 25, 2022
b563c59
Merge pull request #247 from thetejasmagade/patch-1
gouravthakur39 Jun 25, 2022
f8037a0
Merge pull request #245 from lazy-dude/patch-21
gouravthakur39 Jun 25, 2022
f219441
Merge pull request #206 from anishtilak16/update
gouravthakur39 Jun 25, 2022
4d545ff
Merge pull request #204 from adarsh1mehra/master
gouravthakur39 Jun 25, 2022
2a1ccb0
Merge pull request #201 from swt02026/master
gouravthakur39 Jun 25, 2022
602cbc8
Merge pull request #200 from Rochisha24/master
gouravthakur39 Jun 25, 2022
8ea437b
Merge pull request #193 from Mansi-1120/patch-3
gouravthakur39 Jun 25, 2022
3b5ccb5
Merge pull request #192 from Mansi-1120/patch-2
gouravthakur39 Jun 25, 2022
d69d3bf
Merge pull request #186 from spyic/patch-1
gouravthakur39 Jun 25, 2022
7641745
Merge pull request #185 from tyadav4268/patch-1
gouravthakur39 Jun 25, 2022
272ccfb
Merge pull request #181 from PranjalBagal/patch-1
gouravthakur39 Jun 25, 2022
f0fcb09
Merge pull request #180 from sonal10red100/master
gouravthakur39 Jun 25, 2022
dc895e2
Merge pull request #175 from itzNikhilll/master
gouravthakur39 Jun 25, 2022
47d0958
Merge pull request #170 from nivanjanapramod/master
gouravthakur39 Jun 25, 2022
a29b92f
Merge pull request #167 from Shrutijain005/master
gouravthakur39 Jun 25, 2022
46938cf
Merge pull request #164 from sonucodes/master
gouravthakur39 Jun 25, 2022
9506d74
Merge pull request #163 from DeepanshAgrawal/patch-2
gouravthakur39 Jun 25, 2022
0636916
Update README.md
gouravthakur39 Jun 25, 2022
05c767e
Merge pull request #157 from Ritika-Das/patch-1
gouravthakur39 Jun 25, 2022
41d84ab
Merge pull request #149 from shreyanshthakur/patch-1
gouravthakur39 Jun 25, 2022
47ee95b
Merge pull request #148 from sg7801/patch-1
gouravthakur39 Jun 25, 2022
90d52ce
Merge pull request #141 from jindalabhishek1/master
gouravthakur39 Jun 25, 2022
40bda25
Update README.md
gouravthakur39 Jun 25, 2022
0eec857
Create DynamicMemoryAllocation
thesantoso Jul 7, 2022
373d27c
Merge pull request #263 from thesantoso/master
gouravthakur39 Jul 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
199 changes: 199 additions & 0 deletions ARRAY.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
//ARRAY simple operations
#include<stdio.h>
#include<stdlib.h>

int arr[100],i,j,position,n,element,choice;

void menu();

void insertion(){
printf("ENTER THE POSITION YOU WANT TO ENTER THE ELEMENT");
scanf("%d",&position);
position=position-1;
if(position>n-1){
printf("\n INVALID POSITION\n");
menu();
}
printf("ENTER THE ELEMENT ");
scanf("%d",&element);
for(i=n;i>=position;i--){
arr[i+1]=arr[i];
}
arr[position]=element;
n=n+1;
menu();
}

void traversing(){
printf("\n THE ARRAY ENTERED IS:--\n");
for(i=0;i<n;i++){
printf("%d\t",*(arr+i));
}
menu();
}

void deletion(){
printf("ENTER THE POSITION OF THE ELEMENT TO BE DELETED");
scanf("%d",&position);
position=position-1;
if(position>n-1){
printf("\n INVALID POSITION\n");
menu();
}
for(i=position;i<n;i++){
arr[i]=arr[i+1];
}
printf("ELEMENT IS DELETED!!!\n");
n=n-1;
menu();
}

void updation(){
printf("ENTER THE POSITION WHERE U WANT TO UPDATE");
scanf("%d",&position);
if(position>n){
printf("\n INVALID POSITION\n");
menu();
}
printf("\n ENTER THE ELEMENT :-");
scanf("%d",&element);
arr[position]=element;

}

void linear_search(){
printf("ENTER THE ELEMENT YOU WANT TO SEARCH\n");
scanf("%d",&element);
for(i=0;i<n;i++){
if(arr[i] == element){
printf("ELEMENT FOUND AT THE POSITION %d\n\n",i+1);
choice=20;
break;
}
}
if(choice!=20){
printf("\nELEMNT NOT FOUND!!!");
}
menu();
}
bubble_sort_algo(){
for(i=0;i<n;i++){
for(j=0;j<n-i-1;j++){
if(arr[j] > arr[j+1]){
arr[j]=arr[j]+arr[j+1];
arr[j+1]=arr[j]-arr[j+1];
arr[j]=arr[j]-arr[j+1];
}
}
}
}
void bubble_sort(){
bubble_sort_algo();
printf("\nTHE ARRAY HAS BEEN SORTED\n");
menu();
}

void binary_search(){
printf("ENTER THE ELEMENT YOU WANT TO SEARCH\n");
scanf("%d",&element);
int beg,mid,end,check;
check=0;
beg=0;
end=n-1;
bubble_sort_algo();
while(beg<=end){
mid=(beg+end)/2;
if(arr[mid]==element){
printf("ELEMENT FOUND AT POSITION: %d, AFTER THE SORTING",mid+1);
check=10;
break;
}
else if(arr[mid]>element){
end = mid-1;
}
else if(arr[mid]<element){
beg = mid+1;
}
}
if(check!=10){
printf("ELEMENT NOT FOUND IN THE ARRAY!!!");
}
menu();
}

selection_sort(){
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(arr[i]>arr[j]){
arr[i]=arr[i]+arr[j];
arr[j]=arr[i]-arr[j];
arr[i]=arr[i]-arr[j];
}
}
}
printf("ARRAY IS SORTED");
menu();
}


void menu(){
while(1){
printf("\n1. INSERTION\t 2. UPDATION\t 3. TRAVERSING\t 4. DELETION\t 5.EXIT\t 6. RECREATE THE ARRAY \n");
printf("7. LINEAR SEARCH\t 8. BUBBLE SORT\t 9. BINARY SEARCH\t 10. SELECTION SORT\n\n");
scanf("%d",&choice);
switch(choice){
case 1:
insertion();
break;
case 2:
updation();
break;
case 3:
traversing();
break;
case 4:
deletion();
break;
case 5:
exit(1);
case 6:
main();
break;
case 7:
linear_search();
break;
case 8:
bubble_sort();
break;
case 9:
binary_search();
break;
case 10:
selection_sort();
break;
default:
menu();
break;
}
}

}

int main(){

printf("ENTER THE ELEMENTS OF ARRAY");
i=0;
while(1){
printf("\nENTER THE ELEMENT:-\n");
scanf("%d",arr+i);
printf("\nDO YOU WANT TO ENTER ANOTHER ELEMENT PRESS ANY KEY ELSE PRESS 1\n");
scanf("%d",&choice);
if(choice == 1){
n=i+1;
menu();
}
i++;
}

return 0;
}
28 changes: 28 additions & 0 deletions Adding_Fractions.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdio.h>
int main(){
/* variable declaration */
int numerator1, numerator2, denominator1, denominator2,
num_result, denom_result ;
/* Read each fraction */
printf("Please provide the first numerator:\n");
scanf("%d",&numerator1);
printf("Please provide the first denominator:\n");
scanf("%d",&denominator1);
printf("Please provide the second numerator:\n");
scanf("%d",&numerator2);
printf("Please provide the second denominator:\n");
scanf("%d",&denominator2);
/*compare the demonators*/
if ( denominator1 == denominator2 ) {
num_result = numerator1 + numerator2;
denom_result = denominator1; /* or 2, they are equal */
} else {
num_result = (numerator1 * denominator2) + (numerator2 * denominator1 );
denom_result = denominator1 * denominator2;
}
printf("The result of %d / %d + %d / %d is: %d / %d \n", numerator1,denominator1, numerator2, denominator2,num_result,denom_result);
return 0;
}



8 changes: 8 additions & 0 deletions Addition.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include<stdio.h>
void main()
{ int a,b,c;
printf("Enter two Numbers : ");
scanf("%d %d",&a,&b);
c=a+b;
printf("The Sum is %d",c);
}
30 changes: 30 additions & 0 deletions Address of 1-D array
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//The & operator is used to get the address.
//But in case of array the name of array itself returns its address.
//In array the elements occupy consecutive address,
//therefore incrementing it by 1 each time would give
//the address of next element.

#include<stdio.h>
int main()
{
int a[100],i,n,*add;

printf("enter the size: ");
scanf("%d",&n);

printf("enter the numbers: \n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}

for(i=0;i<n;i++)
{
add=a+i;
//add = &a[i]; would also return the same thing.
printf("The address of element %d is %u.\n",*add, add);

//Notice: As size of int is 4-byte the differnce in address
//of cosecutive elements is 4.
}
}
71 changes: 71 additions & 0 deletions Anagram-Program-in-C
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int checkAnagram(char *str1, char *str2);

int main()
{
char str1[100], str2[100];

printf("Function : whether two given strings are anagram :");
printf("\nExample : pears and spare, stone and tones :");

printf(" Input the first String : ");
fgets(str1, sizeof str1, stdin);
printf(" Input the second String : ");
fgets(str2, sizeof str2, stdin);

if(checkAnagram(str1, str2) == 1)
{
str1[strlen(str1)-1] = '\0';
str2[strlen(str2)-1] = '\0';
printf(" %s and %s are Anagram.\n\n",str1,str2);
}
else
{
str1[strlen(str1)-1] = '\0';
str2[strlen(str2)-1] = '\0';
printf(" %s and %s are not Anagram.\n\n",str1,str2);
}
return 0;
}


//Function to check whether two passed strings are anagram or not

int checkAnagram(char *str1, char *str2)
{
int str1ChrCtr[256] = {0}, str2ChrCtr[256] = {0};
int ctr;

/* check the length of equality of Two Strings */

if(strlen(str1) != strlen(str2))
{
return 0;
}

//count frequency of characters in str1

for(ctr = 0; str1[ctr] != '\0'; ctr++)
{
str1ChrCtr[str1[ctr]]++;
}

//count frequency of characters in str2

for(ctr = 0; str2[ctr] != '\0'; ctr++)
{
str2ChrCtr[str2[ctr]]++;
}

//compare character counts of both strings

for(ctr = 0; ctr < 256; ctr++)
{
if(str1ChrCtr[ctr] != str2ChrCtr[ctr])
return 0;
}
return 1;
}
8 changes: 8 additions & 0 deletions Area_of_Circle.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include<stdio.h>
void main()
{ float a,r;
printf("Enter the Radius : ");
scanf("%f",&r);
a=3.14*r*r;
printf("Area is %f",a);
}
8 changes: 8 additions & 0 deletions Area_of_Square.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include<stdio.h>
void main()
{ float a,r;
printf("Enter the Radius : ");
scanf("%f",&s);
a=s*s;
printf("Area is %f",a);
}
10 changes: 10 additions & 0 deletions Area_of_Triangle.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include<stdio.h>
void main()
{ float a,b,h;
printf("Enter the base : ");
scanf("%f",&b);
printf("Enter the height : ");
scanf("%f",&h);
a=0.5*b*h;
printf("Area is %f",a);
}
24 changes: 24 additions & 0 deletions Automorphic_number.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main() {
int num, sqr, temp, last;
int n = 0;
printf("Enter a number \n");
scanf("%d", & num);
sqr = num * num; //calculating square of num
temp = num;
//Counting number of digits
while (temp > 0) {
n++;
temp = temp / 10;
}
//Extracting last n digits
int den = floor(pow(10, n));
last = sqr % den;
if (last == num)
printf("Automorphic number \n");
else
printf("Not Automorphic \n");
return 0;
}