C Language π¨βπ»
This channel will serve you programs of C language. Admin : @jeNiShsoNi Useful channels : @c_channels @DeCODE_C @pyGuru
Show moreπ Analytical overview of Telegram channel C Language π¨βπ»
Channel C Language π¨βπ» (@c_codings) is an active participant. Currently, the community unites 62 093 subscribers, ranking 1 456 in the Technologies & Applications category.
π Audience metrics and dynamics
Since its creation on Π½Π΅Π²ΡΠ΄ΠΎΠΌΠΎ, the project has demonstrated rapid growth, gathering an audience of 62 093 subscribers.
According to the latest data from 02 December, 2024, the channel demonstrates stable activity. Although there has been a change in the number of participants by 0 over the last 30 days and by 0 over the last 24 hours, overall reach remains high.
- Verification status: Not verified
- Engagement rate (ER): The average audience engagement rate is 0%. Within the first 24 hours after publication, content typically collects N/A% reactions from the total number of subscribers.
- Post reach: On average, each post receives 0 views. Within the first day, a publication typically gains 0 views.
- Reactions and interaction: The audience actively supports content: the average number of reactions per post is 0.
π Description and content policy
The author describes the resource as a platform for expressing subjective opinions:
βThis channel will serve you programs of C language.
Admin : @jeNiShsoNi
Useful channels :
@c_channels
@DeCODE_C
@pyGuruβ
Thanks to the high frequency of updates (latest data received on 03 December, 2024), the channel maintains relevance and a high level of publication reach. Analytics show that the audience actively interacts with content, making it an important point of influence in the Technologies & Applications category.
Data loading in progress...
| 2 | 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 | 54 261 |
| 3 | 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 | 18 874 |
| 4 | 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 | 49 341 |
| 5 | 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 | 60 427 |
| 6 | 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 | 82 478 |
| 7 | 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 | 76 623 |
| 8 | 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 | 77 031 |
| 9 | 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 | 66 168 |
| 10 | 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 | 107 699 |
| 11 | 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 | 99 707 |
| 12 | 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 | 79 066 |
| 13 | 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 | 79 103 |
| 14 | 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 | 75 474 |
| 15 | 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 | 72 275 |
| 16 | 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 | 78 365 |
| 17 | 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 | 75 581 |
| 18 | 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 | 75 976 |
| 19 | 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 | 75 854 |
| 20 | 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 | 80 826 |
