C Language πŸ‘¨β€πŸ’» @c_codings Channel on Telegram

C Language πŸ‘¨β€πŸ’»

@c_codings


This channel will serve you programs of C language.
Admin : @jeNiShsoNi

Useful channels :
@c_channels
@DeCODE_C
@pyGuru

C Language πŸ‘¨β€πŸ’» (English)

Are you looking to enhance your programming skills in C language? Look no further than the 'C Language πŸ‘¨β€πŸ’»' Telegram channel! This channel, managed by the talented @jeNiShsoNi, is dedicated to providing you with a collection of programs in C language. Whether you are a beginner looking to learn the basics or an experienced programmer wanting to sharpen your skills, this channel has something for everyone.

In addition to the valuable content provided by the admin, @jeNiShsoNi, you can also find useful channels such as @c_channels, @DeCODE_C, and @pyGuru. These additional resources will further complement your learning experience and help you become a proficient C programmer.

Don't miss out on the opportunity to join a community of like-minded individuals who share a passion for C programming. Stay updated on the latest programs, tips, and tricks by joining the 'C Language πŸ‘¨β€πŸ’»' Telegram channel today!

C Language πŸ‘¨β€πŸ’»

22 Aug, 10:46


144. Circular Link List.

#include<stdio.h>
#include<stdlib.h>

typedef struct Node {
int data;
struct Node *next;
} node;

void insert(node *pointer, int data)
{
node *start = pointer;

while (pointer->next != start)
{
pointer = pointer->next;
}

pointer->next = (node *)
malloc(sizeof(node));
pointer = pointer->next;
pointer->data = data;
pointer->next = start;
printf("%d entered.\n", data);
}

int find(node *pointer, int key)
{
node *start = pointer;
pointer = pointer->next;
while (pointer != start)
{
if (pointer->data == key)
{
return 1;
}
pointer = pointer->next;
}
return 0;
}

void delete(node *pointer, int data)
{
node *start = pointer;
while(pointer->next!=start &&
(pointer->next)->data != data)
{
pointer = pointer->next;
}
if(pointer->next==start)
{
printf("Element %d is not present in the list\n",data);
return;
}
node *temp;
temp = pointer->next;
printf("%d deleted.\n",data);
pointer->next = temp->next;
free(temp);
return;
}

void print(node *start, node *pointer)
{
if (pointer == start)
{
return;
}
printf("%d ", pointer->data);
print(start, pointer->next);
}

int main()
{
node *start, *temp;
start = (node *) malloc(sizeof(node));
temp = start;
temp->next = start;
printf("1. Insert\n");
printf("2. Delete\n");
printf("3. Print\n");
printf("4. Find\n");
while (1)
{
int query;
scanf("%d", &query);
if (query == 1)
{
int data;
scanf("%d", &data);
insert(start, data);
}
else if (query == 2)
{
int data;
scanf("%d", &data);
delete (start, data);
}
else if (query == 3)
{
printf("The list is ");
print(start, start->next);
printf("\n");
}
else if (query == 4)
{
int data;
scanf("%d", &data);
int status = find(start, data);
if (status)
{
printf("Element Found\n");
}
else
{
printf("Element Not Found\n");
}
}
}
}
@C_Codings

C Language πŸ‘¨β€πŸ’»

08 May, 09:43


143. Program to allocate memory using malloc() and free memory using free().

#include<stdio.h>
#include<stdlib.h>

int main() {

int n, i, *ptr, sum = 0;
printf("Enter total number of elements : ");
scanf("%d", &n);

ptr = (int *) malloc(n * sizeof(int));

if (ptr == NULL) {
printf("Error! Memory not allocated.");
return 0;
}

printf("Enter elements of array : \n");
for (i = 0; i < n; ++i) {
scanf("%d", ptr + i);
sum += *(ptr + i);
}

printf("Elements are :\n");
for (i = 0; i < n; i++) {
printf("%d\n", ptr[i]);
}

free(ptr);
return 0;
}
@C_Codings

C Language πŸ‘¨β€πŸ’»

08 May, 09:33


142. Program to concatenate two strings using pointer.

#include <stdio.h>

void concatenator(char *str, char *substr) {

while (*str)
str++;

while (*substr) {
*str = *substr;
substr++;
str++;
}

*str = '\0';
}

int main() {

char str[100], substr[100];

printf("Enter the source string : ");
gets(str);

printf("\nEnter string to concatenate : ");
gets(substr);

concatenator(str, substr);

printf("String after concatenation is \"%s\"\n", str);

return 0;
}
@C_Codings

C Language πŸ‘¨β€πŸ’»

28 Feb, 18:46


141. WAP to multiply and add two complex numbers

Input :
5
-4
4
6

Output :
Sum is 9 + 2i
Product is 44 + 14i

#include<stdio.h>
#include<conio.h>

typedef struct {
int real;
int imag;
} complex;

void getdata (complex *);
void display (complex);
complex sum(complex,complex);
complex mult(complex,complex);

main() {
complex c1,c2,c3,c4;
getdata(&c1);
getdata(&c2);

c3=sum(c1,c2);
printf("Sum is ");
display(c3);

c4=mult(c1,c2);
printf("Product is ");
display(c4);

getch();
}

void getdata(complex *p) {
printf("Enter real ");
scanf("%d",&p->real);
printf("Enter imag ");
scanf("%d",&p->imag);
}

complex sum(complex c1,complex c2) {
complex t;
t.real=c1.real+c2.real;
t.imag=c1.imag+c2.imag;
return t;
}

complex mult(complex c1,complex c2) {
complex t;
t.real=c1.real*c2.real-c1.imag*c2.imag;
t.imag=c1.real*c2.imag+c2.real*c1.imag;
return t;
}

void display {
if(c.imag>=0)
printf("%d+%di\n",c.real,c.imag);
else
printf("%d%di\n",c.real,c.imag);
}
#program_by : @PLAUnit61398

C Language πŸ‘¨β€πŸ’»

30 Jan, 20:38


140. Program to find day on a particular date

#include<stdio.h>

int isLeapYear(int year){
if(year%4==0){
if(year%100==0 && year%400!=0){
return 0;
}
else{
return 1;
}
}
else{
return 0;
}
}

int main() {
int year;
int refYear=1600, leap=0;
int diff, totalDays,day,month, oddDays;
int lYear[]={3,1,3,2,3,2,3,3,2,3,2,3};
int nYear[]={3,0,3,2,3,2,3,3,2,3,2,3};
char week[7][10]={"sunday",
"monday",
"tuesday",
"wednesday"
,"thursday"
,"friday",
"saturday"};
printf("Enter a date between 1600 to 3000\n");
scanf("%d%d%d",&day,&month,&year);
diff = year - refYear;
while(refYear < year){
if(isLeapYear(refYear))
leap++;
refYear++;
}
totalDays = leap*366 + (diff-leap)*365;
oddDays = totalDays%7;

if(isLeapYear(year)){
for(int i=0;i<month-1;i++){
oddDays+=lYear[i];
}
oddDays+=day%7;
}
else{
for(int i=0;i<month-1;i++){
oddDays+=nYear[i];
}
oddDays+=day%7;
}
printf("Day on %d/%d/%d ",day,month,year);
printf("%s",week[(5+oddDays)%7]);
return 0;
}
#program_by : @Vecto_r

C Language πŸ‘¨β€πŸ’»

30 Nov, 02:40


139. Program to read multiline string using scanf.

#include<stdio.h>
int main(void) {

char str[100];
// reading multline string with '.' as a delimiter
scanf("%[^.]",str);

printf("%s",str);

return 0;
}
#program_by : @freakyLuffy

C Language πŸ‘¨β€πŸ’»

30 Nov, 02:38


138. Program to split words from a string using strtok function.

#include <stdio.h>
#include<string.h>
int main(void) {
char str[]="Welcome to C language";
char *token=strtok(str," ");
while(token!=NULL)
{
printf("%s\n",token);
token=strtok(NULL," ");
}
return 0;
}
#program_by : @freakyLuffy

C Language πŸ‘¨β€πŸ’»

17 Nov, 19:35


137. Program to check whether the number is palindrome or not using recursion.

#include<stdio.h>

int checkPalindrome(int);

int main() {

int n, sum;

printf("Enter a number : ");
scanf("%d",&n);

sum = checkPalindrome(n);

if(n == sum)
printf("%d is a palindrome", n);
else
printf("%d is not a palindrome", n);

return 0;
}

int checkPalindrome(int n) {

static int sum=0, r;
if(n != 0)
{
r = n % 10;
sum = sum * 10 + r;
checkPalindrome(n/10);
}
return sum;
}
@C_Codings

C Language πŸ‘¨β€πŸ’»

17 Nov, 06:54


136. Binary search using recursion

#include<stdio.h>

int binary(int arr[], int n, int search, int l, int u);

int main()
{
int arr[10], i, n, search, c, l, u;

printf("Enter the size of an array : ");
scanf("%d", &n);

for (i = 0; i < n; i++)
{
printf("Enter the element %d : ", i+1);
scanf("%d", &arr[i]);
}

printf("Enter the number to be search: ");
scanf("%d", &search);

l = 0, u = n - 1;
c = binary(arr, n, search, l, u);

if (c == 0)
printf("Number not found.");
else
printf("Number found.");

return 0;
}

int binary(int arr[], int n, int search, int l, int u)
{

int mid, c = 0;

if (l <= u)
{
mid = (l + u) / 2;
if (search == arr[mid])
{
c = 1;
}
else if (search < arr[mid])
{
return binary(arr, n, search, l, mid - 1);
}
else
return binary(arr, n, search, mid + 1, u);
}
else
return c;
}
@C_Codings

C Language πŸ‘¨β€πŸ’»

16 Jul, 18:31


135. Sieve of Eratosthenes : An algorithm to generate all the prime numbers within an range.

#include <stdio.h>
#define size 1000

int main (void)
{
int n;
scanf("%d",&n);
int arr[size]={0};

for(int i=2;i*i<=n;i++)
{
for(int j=i;i*j<=n;j++)
{
arr[i*j]=1;
}
}
for(int i=2;i<=n;i++)
{
if(!arr[i])
printf("%d ",i);
}
return 0;
}
#program_by : @freakyLuffy

C Language πŸ‘¨β€πŸ’»

12 Jul, 18:22


134. Program to delete a node for a given element from linked list.

#include <stdio.h>
#include<stdlib.h>

typedef struct node {
int data;
struct node *next;
}Node;

int main(void)
{
Node*temp;
Node*start=NULL;
Node* p=NULL;

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

while(n--)
{
temp=(Node *)malloc(sizeof(struct node));
scanf("%d",&temp->data);
temp->next=NULL;

if(start==NULL)
{
start=temp;
p=temp;
}
else
{
p->next=temp;
p=temp;
}
}

printf("Element to delete : ");
int ele; scanf("%d",&ele); printf("%d\n",ele);
Node*prev=start;
Node*cur=start;

while(cur!=NULL)
{
if(start->data==ele)
{
start=start->next;
}

if(cur->data==ele)
{
prev->next=cur->next;
free(cur);
break;
}
prev=cur;
cur=cur->next;

if(cur==NULL)
{
printf("Element doesn't exist!");
exit(0);
}
}

while(start!=NULL)
{
if(start->next!=NULL)
printf("%d->",start->data);
else
printf("%d",start->data);

start=start->next;
}

return 0;
}
#program_by : @freakyLuffy

C Language πŸ‘¨β€πŸ’»

12 Jul, 18:06


133. Program for creating and displaying a linked list.

#include <stdio.h>
#include<stdlib.h>

typedef struct node {
int data;
struct node *next;
}Node;

int main(void)
{
Node*temp;
Node*start=NULL;
Node* p=NULL;

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

while(n--)
{
temp=(Node *)malloc(sizeof(struct node));
scanf("%d",&temp->data);
temp->next=NULL;

if(start==NULL)
{
start=temp;
p=temp;
}
else
{
p->next=temp;
p=temp;
}

}

while(start!=NULL)
{
if(start->next!=NULL)
printf("%d->",start->data);
else
printf("%d",start->data);

start=start->next;
}
return 0;
}
#program_by : @freakyLuffy

C Language πŸ‘¨β€πŸ’»

22 Jun, 17:23


132. Pattern


@ @
@ @ @ @
@ @ @
@ @ @
@ @ @ @
@ @ @ @ @
@ @ @
@ @ @ @ @
@ @ @ @
@ @ @
@ @ @
@ @ @ @
@ @



#include<stdio.h>
int main()
{
int n,x,y;
scanf("%d",&n);

if(n%2==0)
n=n+1;

for(y=3*n/2; y>=-3*(n/2); y--)
{
for(x=-3*(n/2); x<=3*(n/2); x++)
{
if((x>=-1*n/2 && x<=n/2) || (y>=-1*n/2 && y<=n/2))
{
if(x==y || x==-y)
printf("@ ");
else if((y<=0 || y>=n/2) && (x+y==n-1))
printf("@ ");
else if((y>=0 || y<=-n/2) && (x+y==1-n))
printf("@ ");
else if((x<=0 || x>=n/2) && (x-y==n-1))
printf("@ ");
else if((x>=0 || x<=-n/2) && (x-y==1-n))
printf("@ ");
else
printf(" ");
}
else
{
if(x+y==(n-1)*2)
printf("@ ");
else if(x+y==(1-n)*2)
printf("@ ");
else if(x-y==(n-1)*2)
printf("@ ");
else if(x-y==(1-n)*2)
printf("@ ");
else
printf(" ");
}
}
printf("\n");
}
}
#program_by : @I_am_liberal

C Language πŸ‘¨β€πŸ’»

10 Jun, 14:16


131. Pattern

5 5
54 45
543 345
5432 2345
543212345
5432 2345
543 345
54 45
5 5


#include <stdio.h>
int main()
{
int i,j,n;
scanf("%d",&n);

for(i=n;i>=1;i--) {
for(j=n;j>=1;j--) {
if(j>=i)
printf("%d",j);
else
printf(" ");
}
for(j=2;j<=n;j++) {
if(j>=i)
printf("%d",j);
else
printf(" ");
}
printf("\n");
}

//down
for(i=2;i<=n;i++) {
for(j=n;j>=1;j--) {
if(j>=i)
printf("%d",j);
else
printf(" ");
}
for(j=2;j<=n;j++) {
if(j>=i)
printf("%d",j);
else
printf(" ");
}
printf("\n");
}
}
#program_by : @shubhamkkc

C Language πŸ‘¨β€πŸ’»

08 Jun, 05:43


130. Swastika pattern.

* * * * *
* *
* *
* * * * * * *
* *
* *
* * * * *


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

for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(i==1)
{
if(j>(n/2)||j==1)
printf("* ");
else
printf(" ");
}
else if(i==n)
{
if(j<=(n/2+1)||j==n)
printf("* ");
else
printf(" ");
}
else if(i==(n+1)/2)
printf("* ");

else if(i<=n/2&&i!=1)
{
if(j==1||j==(n+1)/2)
printf("* ");
else
printf(" ");
}
else
{
if(j==n||j==(n+1)/2)
printf("* ");
else
printf(" ");
}
}
printf("\n");
}
return 0;
}
#program_by : @freakyLuffy

C Language πŸ‘¨β€πŸ’»

21 Apr, 16:13


129. Pattern

1
8 2
14 9 3
19 15 10 4
23 20 16 11 5
26 24 21 17 12 6
28 27 25 22 18 13 7

#include<stdio.h>
int main() {

int n,i,j,k,l=1,d;
scanf("%d",&n);
for(i=0;i<n;++i)
{
for(j=i-1;j>=0;--j)
{
d=n-1;
l=i+1;
for(k=0;k<=j;++k)
{
l+=d;
d--;
}
printf("%d ",l);
}
printf("%d\n",i+1);
}
return 0;
}
#program_by : @Sherry060199

C Language πŸ‘¨β€πŸ’»

18 Apr, 06:49


128. Pattern

1
3 2
4 5 6
10 9 8 7
11 12 13 14 15
21 20 19 18 17 16


#include<stdio.h>
int main()
{
int i,j,k,l,n;

scanf("%d",&n);

for(k=i=1;i<=n;i++)
{
l=k+i-1;
for(j=1;j<=i;j++)
{
if(i%2==1)
printf("%d ",k);
else
printf("%d ",l);
k++;
l--;
}
printf("\n");
}
return 0;
}
#program_by : @aShish_bhushan

C Language πŸ‘¨β€πŸ’»

07 Apr, 03:20


127. Program for infix to postfix conversion.

#include<stdio.h>
char ifix[200],pfix[200],stack[100];
int p=0,s=0,i=0;
void fun()
{
if(ifix[i]==')')
{
s--;
while(stack[s]!='(')
pfix[p++]=stack[s--];
}
if(ifix[i]=='+' || ifix[i]=='-')
{
if(!s)
stack[s++]=ifix[i];
else if(stack[s-1]=='(')
stack[s++]=ifix[i];
else
{
s--;
while(s!=-1 && stack[s]!='(')
{
pfix[p++]=stack[s--];
}
stack[++s]=ifix[i];
s++;
}
}
}
int main()
{
printf("Enter your infix expression(using operators +, -, %%, /, *) : ");
scanf("%s",ifix);
for(i;ifix[i]!='\0';i++)
{
if(ifix[i]!='*' && ifix[i]!='/' && ifix[i]!='-' && ifix[i]!='+' && ifix[i]!='(' && ifix[i]!=')' && ifix[i]!='%')
pfix[p++]=ifix[i];
else if(ifix[i]=='(' || ifix[i]=='*' || ifix[i]=='/' || ifix[i]=='%')
stack[s++]=ifix[i];
else
fun();
}
if(ifix[i]=='\0')
{
if(s)
{
s--;
while(s!=-1)
{
if(stack[s]==')' || stack[s]=='(')
s--;
pfix[p++]=stack[s--];
}
}
pfix[p]='\0';
}
printf("The postfix expression is : %s",pfix);
return 0;
}
//used by taking into considering operators +, -, /, *, %, (, )
#program_by : @sidg28

C Language πŸ‘¨β€πŸ’»

18 Mar, 18:23


126. Program to sort array using Bubble Sort.

#include<stdio.h>
#include<conio.h>

void main()
{
int total, element[100], i, j, temp;
clrscr();

printf("Enter total number of elements :");
scanf("%d", &total);

for(i=0; i<total; i++)
{
printf("Enter element no%d :", i+1);
scanf("%d", &element[i]);
}

for (i=0; i<(total - 1); i++)
{
for (j = 0; j < total - 1; j++)
{
if (element[j] > element[j + 1])
{
temp = element[j];
element[j] = element[j + 1];
element[j + 1] = temp;
}
}
}

printf("\nSorted list in ascending order :");

for (i = 0; i < total; i++)
{
printf("\n%d", element[i]);
}
getch();
}
//To sort in descending order, use < (less than) in if condition.
@C_Codings

C Language πŸ‘¨β€πŸ’»

28 Jan, 17:36


125. Program to sort array using Selection Sort.

#include<stdio.h>
#include<conio.h>

void main()
{
int array[20], n, i, j, pos, temp;
clrscr();

printf("Enter total number of elements :");
scanf("%d", &n);

for (i = 0; i < n; i++)
{
printf("\nEnter element number %d : ", i+1);
scanf("%d", &array[i]);
}

for (i = 0; i < (n - 1); i++)
{
pos = i;
for (j = i + 1; j < n; j++)
{
if (array[pos] > array[j])
pos = j;
}
if (pos != i)
{
temp = array[i];
array[i] = array[pos];
array[pos] = temp;
}
}

printf("\nSorted elements :");

for (i = 0; i < n; i++)
printf("%d\n", array[i]);

getch();
}
@C_Codings

62,230

subscribers

0

photos

0

videos