102. Program to calculate the length of string without using strlen() function.
#include<stdio.h>
#include<conio.h>
void main()
{
char s[1000], i;
clrscr();
printf("Enter a string : ");
scanf("%s", s);
for (i = 0; s[i] != '\0'; ++i);
printf("Length of string : %d", i);
getch();
}
//for more update join us on telegram
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
char s[1000], i;
clrscr();
printf("Enter a string : ");
scanf("%s", s);
for (i = 0; s[i] != '\0'; ++i);
printf("Length of string : %d", i);
getch();
}
//for more update join us on telegram
@programming_and_coding
103. Program to check the palindrome of string.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char text[100];
int begin, middle, end, length = 0;
clrscr();
printf("Enter the string to check if it is a palindrome : \n");
gets(text);
while (text[length] != '\0')
{
length++;
}
end = length - 1;
middle = length / 2;
for (begin = 0; begin < middle; begin++)
{
if (text[begin] != text[end])
{
printf("\nString is not a palindrome.");
break;
}
end--;
}
if (begin == middle)
printf("\nString is Palindrome.");
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char text[100];
int begin, middle, end, length = 0;
clrscr();
printf("Enter the string to check if it is a palindrome : \n");
gets(text);
while (text[length] != '\0')
{
length++;
}
end = length - 1;
middle = length / 2;
for (begin = 0; begin < middle; begin++)
{
if (text[begin] != text[end])
{
printf("\nString is not a palindrome.");
break;
}
end--;
}
if (begin == middle)
printf("\nString is Palindrome.");
getch();
}
@programming_and_coding
104. Program to check the palindrome of word using array.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char word[100];
int length, counter;
clrscr();
printf("Enter a word : ");
scanf("%s", word);
length = strlen(word);
int flag = 1;
for (counter = 0; counter < length / 2 && flag; counter++)
{
if (word[counter] != word[length - counter - 1])
{
flag = 0;
break;
}
}
if (flag)
{
printf("\n%s is a palindrome.", word);
}
else
{
printf("\n%s is NOT a palindrome.", word);
}
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char word[100];
int length, counter;
clrscr();
printf("Enter a word : ");
scanf("%s", word);
length = strlen(word);
int flag = 1;
for (counter = 0; counter < length / 2 && flag; counter++)
{
if (word[counter] != word[length - counter - 1])
{
flag = 0;
break;
}
}
if (flag)
{
printf("\n%s is a palindrome.", word);
}
else
{
printf("\n%s is NOT a palindrome.", word);
}
getch();
}
@programming_and_coding
105. Program to remove white space in string.
#include<string.h>
#include<stdio.h>
#include<conio.h>
void main()
{
int i = 0, j = 0, len;
char buff[50];
clrscr();
printf("Enter String with white space : ");
gets(buff);
len = (int) strlen(buff);
while (i != len)
{
if (buff[i] != ' ')
buff[j++] = buff[i];
i++;
}
buff[j] = 0;
printf("\nYour String is : %s.", buff);
getch();
}
@programming_and_coding
#include<string.h>
#include<stdio.h>
#include<conio.h>
void main()
{
int i = 0, j = 0, len;
char buff[50];
clrscr();
printf("Enter String with white space : ");
gets(buff);
len = (int) strlen(buff);
while (i != len)
{
if (buff[i] != ' ')
buff[j++] = buff[i];
i++;
}
buff[j] = 0;
printf("\nYour String is : %s.", buff);
getch();
}
@programming_and_coding
106. Program to reverse the string.
#include<stdio.h>
#include<conio.h>
#include<string.h>
char *strrev(char *str)
{
char *p1, *p2;
if (!str || !*str)
return str;
for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2)
{
*p1 ^= *p2;
*p2 ^= *p1;
*p1 ^= *p2;
}
return str;
}
void main()
{
char arr[100];
clrscr();
printf("\nEnter a string to reverse : ");
gets(arr);
strrev(arr);
printf("\nReverse of entered string is : %s", arr);
getch();
}
Join @programming_and_coding
#include<stdio.h>
#include<conio.h>
#include<string.h>
char *strrev(char *str)
{
char *p1, *p2;
if (!str || !*str)
return str;
for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2)
{
*p1 ^= *p2;
*p2 ^= *p1;
*p1 ^= *p2;
}
return str;
}
void main()
{
char arr[100];
clrscr();
printf("\nEnter a string to reverse : ");
gets(arr);
strrev(arr);
printf("\nReverse of entered string is : %s", arr);
getch();
}
Join @programming_and_coding
107. Program to reverse the string using pointer.
#include<stdio.h>
#include<conio.h>
void main()
{
char str_array[10000], *ptr;
int i, len;
clrscr();
printf("Enter a string : ");
gets(str_array);
ptr = str_array;
for (i = 0; i < 10000; i++)
{
if (*ptr == '\0')
break;
ptr++;
}
len = i;
ptr--;
printf("\nReversed String is : ");
for (i = len; i > 0; i--)
{
printf("%c", *ptr--);
}
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
char str_array[10000], *ptr;
int i, len;
clrscr();
printf("Enter a string : ");
gets(str_array);
ptr = str_array;
for (i = 0; i < 10000; i++)
{
if (*ptr == '\0')
break;
ptr++;
}
len = i;
ptr--;
printf("\nReversed String is : ");
for (i = len; i > 0; i--)
{
printf("%c", *ptr--);
}
getch();
}
@programming_and_coding
108. Program to sort the strings.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i, j, n;
char str[20][20], temp[20];
clrscr();
printf("Enter the number of string to be sorted : ");
scanf("%d", &n);
for (i = 0; i <= n; i++)
gets(str[i]);
for (i = 0; i <= n; i++)
for (j = i + 1; j <= n; j++)
{
if (strcmp(str[i], str[j]) > 0)
{
strcpy(temp, str[i]);
strcpy(str[i], str[j]);
strcpy(str[j], temp);
}
}
printf("\nSorted string :");
for (i = 0; i <= n; i++)
{
puts(str[i]);
}
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i, j, n;
char str[20][20], temp[20];
clrscr();
printf("Enter the number of string to be sorted : ");
scanf("%d", &n);
for (i = 0; i <= n; i++)
gets(str[i]);
for (i = 0; i <= n; i++)
for (j = i + 1; j <= n; j++)
{
if (strcmp(str[i], str[j]) > 0)
{
strcpy(temp, str[i]);
strcpy(str[i], str[j]);
strcpy(str[j], temp);
}
}
printf("\nSorted string :");
for (i = 0; i <= n; i++)
{
puts(str[i]);
}
getch();
}
@programming_and_coding
109. Program to swap two strings.
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
char str1[100], str2[100], *temp;
clrscr();
printf("Enter first string : ");
gets(str1);
printf("Enter second string : ");
gets(str2);
printf("\nBefore Swapping : \n");
printf("First string : %s\n", str1);
printf("Second string : %s\n", str2);
temp = (char *) malloc(100);
strcpy(temp, str1);
strcpy(str1, str2);
strcpy(str2, temp);
printf("\nAfter Swapping : \n");
printf("First string : %s\n", str1);
printf("Second string : %s\n", str2);
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
char str1[100], str2[100], *temp;
clrscr();
printf("Enter first string : ");
gets(str1);
printf("Enter second string : ");
gets(str2);
printf("\nBefore Swapping : \n");
printf("First string : %s\n", str1);
printf("Second string : %s\n", str2);
temp = (char *) malloc(100);
strcpy(temp, str1);
strcpy(str1, str2);
strcpy(str2, temp);
printf("\nAfter Swapping : \n");
printf("First string : %s\n", str1);
printf("Second string : %s\n", str2);
getch();
}
@programming_and_coding
110. Program to add two matrix.
#include<stdio.h>
#include<conio.h>
void main()
{
int m, n, c, d, first[10][10], second[10][10], sum[10][10];
clrscr();
printf("Enter the number of rows and columns of matrix :");
scanf("%d%d", &m, &n);
printf("\nEnter the elements of first matrix : \n");
for (c = 0; c < m; c++)
{
for (d = 0; d < n; d++)
{
scanf("%d", &first[c][d]);
}
}
printf("\nEnter the elements of second matrix : \n");
for (c = 0; c < m; c++)
{
for (d = 0; d < n; d++)
{
scanf("%d", &second[c][d]);
}
}
printf("\nSum of entered matrices : \n");
for (c = 0; c < m; c++)
{
for (d = 0; d < n; d++)
{
sum[c][d] = first[c][d] + second[c][d];
printf("%d\t", sum[c][d]);
}
printf("\n");
}
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int m, n, c, d, first[10][10], second[10][10], sum[10][10];
clrscr();
printf("Enter the number of rows and columns of matrix :");
scanf("%d%d", &m, &n);
printf("\nEnter the elements of first matrix : \n");
for (c = 0; c < m; c++)
{
for (d = 0; d < n; d++)
{
scanf("%d", &first[c][d]);
}
}
printf("\nEnter the elements of second matrix : \n");
for (c = 0; c < m; c++)
{
for (d = 0; d < n; d++)
{
scanf("%d", &second[c][d]);
}
}
printf("\nSum of entered matrices : \n");
for (c = 0; c < m; c++)
{
for (d = 0; d < n; d++)
{
sum[c][d] = first[c][d] + second[c][d];
printf("%d\t", sum[c][d]);
}
printf("\n");
}
getch();
}
@programming_and_coding
111. Program to arrange array numbers in ascending order.
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, a, n, number[30];
clrscr();
printf("Enter total numbers : ");
scanf("%d", &n);
printf("\n Enter the numbers :\n");
for (i = 0; i < n; ++i)
{
scanf("%d", &number[i]);
}
for (i = 0; i < n; ++i)
{
for (j = i + 1; j < n; ++j)
{
if (number[i] > number[j])
{
a = number[i];
number[i] = number[j];
number[j] = a;
}
}
}
printf("The numbers arranged in ascending order are :\n");
for (i = 0; i < n; ++i)
{
printf("%d\n", number[i]);
}
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, a, n, number[30];
clrscr();
printf("Enter total numbers : ");
scanf("%d", &n);
printf("\n Enter the numbers :\n");
for (i = 0; i < n; ++i)
{
scanf("%d", &number[i]);
}
for (i = 0; i < n; ++i)
{
for (j = i + 1; j < n; ++j)
{
if (number[i] > number[j])
{
a = number[i];
number[i] = number[j];
number[j] = a;
}
}
}
printf("The numbers arranged in ascending order are :\n");
for (i = 0; i < n; ++i)
{
printf("%d\n", number[i]);
}
getch();
}
@programming_and_coding
112. Program to check whether the matrix is sparse matrix or not.
#include<stdio.h>
#include<conio.h>
void main()
{
static int array[10][10];
int i, j, m, n;
int counter = 0;
clrscr();
printf("Enter the order of the matix : ");
scanf("%d %d", &m, &n);
printf("\nEnter the co-efficients of the matix :\n");
for (i = 0; i < m; ++i)
{
for (j = 0; j < n; ++j)
{
scanf("%d", &array[i][j]);
if (array[i][j] == 0)
{
++counter;
}
}
}
if (counter > ((m * n) / 2))
{
printf("The given matrix is sparse matrix \n");
}
else
{
printf("The given matrix is not a sparse matrix \n");
}
printf("There are %d number of zeros", counter);
getch();
}
Join : @programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
static int array[10][10];
int i, j, m, n;
int counter = 0;
clrscr();
printf("Enter the order of the matix : ");
scanf("%d %d", &m, &n);
printf("\nEnter the co-efficients of the matix :\n");
for (i = 0; i < m; ++i)
{
for (j = 0; j < n; ++j)
{
scanf("%d", &array[i][j]);
if (array[i][j] == 0)
{
++counter;
}
}
}
if (counter > ((m * n) / 2))
{
printf("The given matrix is sparse matrix \n");
}
else
{
printf("The given matrix is not a sparse matrix \n");
}
printf("There are %d number of zeros", counter);
getch();
}
Join : @programming_and_coding
113. Program to delete an element from array.
#include<stdio.h>
#include<conio.h>
void main()
{
int array[100], position, c, n;
clrscr();
printf("Enter total number of elements in array : ");
scanf("%d", &n);
printf("\nEnter element %d : ", n);
for (c = 0; c < n; c++)
scanf("%d", &array[c]);
printf("\nEnter the location from where you wish to delete element : ");
scanf("%d", &position);
if (position >= n + 1)
printf("\nDeletion not possible.");
else
{
for (c = position - 1; c < n - 1; c++)
array[c] = array[c + 1];
printf("\nResultant array is :");
for (c = 0; c < n - 1; c++)
printf("\n%d", array[c]);
}
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int array[100], position, c, n;
clrscr();
printf("Enter total number of elements in array : ");
scanf("%d", &n);
printf("\nEnter element %d : ", n);
for (c = 0; c < n; c++)
scanf("%d", &array[c]);
printf("\nEnter the location from where you wish to delete element : ");
scanf("%d", &position);
if (position >= n + 1)
printf("\nDeletion not possible.");
else
{
for (c = position - 1; c < n - 1; c++)
array[c] = array[c + 1];
printf("\nResultant array is :");
for (c = 0; c < n - 1; c++)
printf("\n%d", array[c]);
}
getch();
}
@programming_and_coding
114. Program to delete given number from array.
#include<stdio.h>
#include<conio.h>
void main()
{
int array[10];
int i, n, pos, element, found = 0;
clrscr();
printf("Enter total number of elements : ");
scanf("%d", &n);
printf("\nEnter the elements : \n");
for (i = 0; i < n; i++)
{
scanf("%d", &array[i]);
}
printf("Input array elements are\n");
for (i = 0; i < n; i++)
{
printf("\n%d", array[i]);
}
printf("\nEnter the element to be deleted : ");
scanf("%d", &element);
for (i = 0; i < n; i++)
{
if (array[i] == element)
{
found = 1;
pos = i;
break;
}
}
if (found == 1)
{
for (i = pos; i < n - 1; i++)
{
array[i] = array[i + 1];
}
printf("\nResultant array elements are : ");
for (i = 0; i < n - 1; i++)
{
printf("\n%d", array[i]);
}
}
else
{
printf("\nElement %d is not found in the array", element);
}
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int array[10];
int i, n, pos, element, found = 0;
clrscr();
printf("Enter total number of elements : ");
scanf("%d", &n);
printf("\nEnter the elements : \n");
for (i = 0; i < n; i++)
{
scanf("%d", &array[i]);
}
printf("Input array elements are\n");
for (i = 0; i < n; i++)
{
printf("\n%d", array[i]);
}
printf("\nEnter the element to be deleted : ");
scanf("%d", &element);
for (i = 0; i < n; i++)
{
if (array[i] == element)
{
found = 1;
pos = i;
break;
}
}
if (found == 1)
{
for (i = pos; i < n - 1; i++)
{
array[i] = array[i + 1];
}
printf("\nResultant array elements are : ");
for (i = 0; i < n - 1; i++)
{
printf("\n%d", array[i]);
}
}
else
{
printf("\nElement %d is not found in the array", element);
}
getch();
}
@programming_and_coding
🚀 **Code Challenge
#115: Mastering Pointers in C!**
Hey Coders! 👩💻👨💻
Let's dive into the world of pointers with today's challenge! 🎯
#include <stdio.h>
int main() {
// Declare an integer variable
int num = 42;
// Declare a pointer and point it to the address of 'num'
int *ptr = #
// Modify the value using the pointer
*ptr += 8;
// Print the updated value
printf("The new value of num is: %d\n", num);
return 0;
}
🤔 Challenge Task:
1. Understand how the pointer
2. Use the pointer to increment the value of
3. Print the updated value of
💡 Hint: Remember to dereference the pointer using
Happy coding! 🚀💻 #CodeChallenge #CProgramming #PointersInC
Share it your friends and family.
@programming_and_coding
#115: Mastering Pointers in C!**
Hey Coders! 👩💻👨💻
Let's dive into the world of pointers with today's challenge! 🎯
#include <stdio.h>
int main() {
// Declare an integer variable
int num = 42;
// Declare a pointer and point it to the address of 'num'
int *ptr = #
// Modify the value using the pointer
*ptr += 8;
// Print the updated value
printf("The new value of num is: %d\n", num);
return 0;
}
🤔 Challenge Task:
1. Understand how the pointer
ptr is initialized.2. Use the pointer to increment the value of
num by 8.3. Print the updated value of
num.💡 Hint: Remember to dereference the pointer using
* to access and modify the value it points to.Happy coding! 🚀💻 #CodeChallenge #CProgramming #PointersInC
Share it your friends and family.
@programming_and_coding
🚀 Code Challenge #115: Array Manipulation in C!
Hello Coders! 👩💻👨💻
Let's continue our coding journey with today's challenge – Manipulating Arrays! 🌐🔍
116: Remove Duplicates from Array
#include<stdio.h>
#include<conio.h>
void main()
{
int array[10];
int i, n, pos, element, found = 0;
clrscr();
printf("Enter total number of elements : ");
scanf("%d", &n);
printf("\nEnter the elements : \n");
for (i = 0; i < n; i++)
{
scanf("%d", &array[i]);
}
printf("Input array elements are\n");
for (i = 0; i < n; i++)
{
printf("\n%d", array[i]);
}
printf("\nEnter the element to be deleted : ");
scanf("%d", &element);
for (i = 0; i < n; i++)
{
if (array[i] == element)
{
found = 1;
pos = i;
break;
}
}
if (found == 1)
{
for (i = pos; i < n - 1; i++)
{
array[i] = array[i + 1];
}
printf("\nResultant array elements are : ");
for (i = 0; i < n - 1; i++)
{
printf("\n%d", array[i]);
}
}
else
{
printf("\nElement %d is not found in the array", element);
}
getch();
}
🤔 Challenge Task:
Modify the provided code to remove duplicates from the array and display the result.
Share with your friend
@programming_and_coding
Happy coding! 🚀💻 #CodeChallenge #CProgramming #ArrayManipulation
Hello Coders! 👩💻👨💻
Let's continue our coding journey with today's challenge – Manipulating Arrays! 🌐🔍
116: Remove Duplicates from Array
#include<stdio.h>
#include<conio.h>
void main()
{
int array[10];
int i, n, pos, element, found = 0;
clrscr();
printf("Enter total number of elements : ");
scanf("%d", &n);
printf("\nEnter the elements : \n");
for (i = 0; i < n; i++)
{
scanf("%d", &array[i]);
}
printf("Input array elements are\n");
for (i = 0; i < n; i++)
{
printf("\n%d", array[i]);
}
printf("\nEnter the element to be deleted : ");
scanf("%d", &element);
for (i = 0; i < n; i++)
{
if (array[i] == element)
{
found = 1;
pos = i;
break;
}
}
if (found == 1)
{
for (i = pos; i < n - 1; i++)
{
array[i] = array[i + 1];
}
printf("\nResultant array elements are : ");
for (i = 0; i < n - 1; i++)
{
printf("\n%d", array[i]);
}
}
else
{
printf("\nElement %d is not found in the array", element);
}
getch();
}
🤔 Challenge Task:
Modify the provided code to remove duplicates from the array and display the result.
Share with your friend
@programming_and_coding
Happy coding! 🚀💻 #CodeChallenge #CProgramming #ArrayManipulation
🚀 Code Challenge #116: Searching in a Sorted Array
Hello, Coding Enthusiasts! 👩💻👨💻
Dive into today's challenge focused on searching in a sorted array! 🔍🌐
Question 116: Binary Search in a Sorted Array
#include <stdio.h>
int binarySearch(int array[], int low, int high, int target) {
while (low <= high) {
int mid = low + (high - low) / 2;
if (array[mid] == target)
return mid;
if (array[mid] < target)
low = mid + 1;
else
high = mid - 1;
}
return -1; // Target not found
}
int main() {
int array[] = {2, 5, 8, 12, 16, 23, 38, 42, 56, 72};
int n = sizeof(array) / sizeof(array[0]);
int target = 23;
int result = binarySearch(array, 0, n - 1, target);
if (result != -1)
printf("Element %d found at index %d", target, result);
else
printf("Element %d not found in the array");
return 0;
}
🤔 Challenge Task:
1. Understand the provided binary search algorithm.
2. Execute the algorithm to find the index of the target element (e.g., 23) in the sorted array.
Happy coding! 🚀💻
Join us on [Telegram](https://t.me/programming_and_coding) for more coding discussions and challenges! #CodeChallenge #CProgramming #BinarySearch
Hello, Coding Enthusiasts! 👩💻👨💻
Dive into today's challenge focused on searching in a sorted array! 🔍🌐
Question 116: Binary Search in a Sorted Array
#include <stdio.h>
int binarySearch(int array[], int low, int high, int target) {
while (low <= high) {
int mid = low + (high - low) / 2;
if (array[mid] == target)
return mid;
if (array[mid] < target)
low = mid + 1;
else
high = mid - 1;
}
return -1; // Target not found
}
int main() {
int array[] = {2, 5, 8, 12, 16, 23, 38, 42, 56, 72};
int n = sizeof(array) / sizeof(array[0]);
int target = 23;
int result = binarySearch(array, 0, n - 1, target);
if (result != -1)
printf("Element %d found at index %d", target, result);
else
printf("Element %d not found in the array");
return 0;
}
🤔 Challenge Task:
1. Understand the provided binary search algorithm.
2. Execute the algorithm to find the index of the target element (e.g., 23) in the sorted array.
Happy coding! 🚀💻
Join us on [Telegram](https://t.me/programming_and_coding) for more coding discussions and challenges! #CodeChallenge #CProgramming #BinarySearch
Telegram
C_Language_Coding
This channel will serve you C language program from basic to advance in a serial order that help you in understand the basic and crack any IT examination in easy way .
Invite other to Subscribe this channel on telegram
@Programming_and_Coding
Invite other to Subscribe this channel on telegram
@Programming_and_Coding
🚀 Coding Chronicles #117: Unleashing the XOR Swap Magic!
Hello, Coding Maestros! 👩💻👨💻
Let's delve into a byte-sized piece of coding wisdom today! 🧠✨
🌐 The Magic of Bit Manipulation: Swapping Variables
Ever heard of swapping variables without a temporary variable? Bit manipulation does the trick! Explore the XOR swap algorithm in this compact code snippet.
💡 Key Takeaway:
Understanding the power of bitwise operations opens doors to efficient coding solutions!
🚀💻 Join our community on [Telegram](https://t.me/programming_and_coding) for more coding adventures! #CodingWisdom #BitManipulation #ProgrammingJourney
Hello, Coding Maestros! 👩💻👨💻
Let's delve into a byte-sized piece of coding wisdom today! 🧠✨
🌐 The Magic of Bit Manipulation: Swapping Variables
#include <stdio.h>🤯 Insight:
void swap(int *a, int *b) {
*a = *a ^ *b;
*b = *a ^ *b;
*a = *a ^ *b;
}
int main() {
int x = 10, y = 20;
printf("Before Swap: x = %d, y = %d\n", x, y);
swap(&x, &y);
printf("After Swap: x = %d, y = %d\n", x, y);
return 0;
}
Ever heard of swapping variables without a temporary variable? Bit manipulation does the trick! Explore the XOR swap algorithm in this compact code snippet.
💡 Key Takeaway:
Understanding the power of bitwise operations opens doors to efficient coding solutions!
🚀💻 Join our community on [Telegram](https://t.me/programming_and_coding) for more coding adventures! #CodingWisdom #BitManipulation #ProgrammingJourney
Telegram
C_Language_Coding
This channel will serve you C language program from basic to advance in a serial order that help you in understand the basic and crack any IT examination in easy way .
Invite other to Subscribe this channel on telegram
@Programming_and_Coding
Invite other to Subscribe this channel on telegram
@Programming_and_Coding
🚀 Tech Insight #119: The Power of Recursion
Hello, Code Enthusiasts! 👩💻👨💻
Let's unravel the mystical realm of recursion today! 🌀✨
🔄 What is Recursion?
Recursion is a programming concept where a function calls itself in its own definition. It's a powerful technique that can simplify complex problems.
🌐 Fibonacci Sequence using Recursion in C:
#include <stdio.h>
int fibonacci(int n) {
if (n <= 1)
return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
int main() {
int n = 5;
printf("Fibonacci sequence up to %d terms:\n", n);
for (int i = 0; i < n; i++) {
printf("%d ", fibonacci(i));
}
return 0;
}
🤔 Why Recursion?
1. Elegant Solutions: Certain problems are naturally expressed using recursion, making the code more elegant.
2. Divide and Conquer: Recursive solutions often follow a divide-and-conquer approach, breaking down problems into smaller, more manageable subproblems.
💬 Let's Discuss with your friends:
Share your thoughts on recursion! Do you find it fascinating or challenging? Have you encountered situations where recursion was the key to a solution?
Join the conversation on [Telegram](https://t.me/programming_and_coding) and let's explore the recursive wonders together! 🚀🗣️ #RecursionMagic #TechInsights #CodingExploration
Hello, Code Enthusiasts! 👩💻👨💻
Let's unravel the mystical realm of recursion today! 🌀✨
🔄 What is Recursion?
Recursion is a programming concept where a function calls itself in its own definition. It's a powerful technique that can simplify complex problems.
🌐 Fibonacci Sequence using Recursion in C:
#include <stdio.h>
int fibonacci(int n) {
if (n <= 1)
return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
int main() {
int n = 5;
printf("Fibonacci sequence up to %d terms:\n", n);
for (int i = 0; i < n; i++) {
printf("%d ", fibonacci(i));
}
return 0;
}
🤔 Why Recursion?
1. Elegant Solutions: Certain problems are naturally expressed using recursion, making the code more elegant.
2. Divide and Conquer: Recursive solutions often follow a divide-and-conquer approach, breaking down problems into smaller, more manageable subproblems.
💬 Let's Discuss with your friends:
Share your thoughts on recursion! Do you find it fascinating or challenging? Have you encountered situations where recursion was the key to a solution?
Join the conversation on [Telegram](https://t.me/programming_and_coding) and let's explore the recursive wonders together! 🚀🗣️ #RecursionMagic #TechInsights #CodingExploration
Telegram
C_Language_Coding
This channel will serve you C language program from basic to advance in a serial order that help you in understand the basic and crack any IT examination in easy way .
Invite other to Subscribe this channel on telegram
@Programming_and_Coding
Invite other to Subscribe this channel on telegram
@Programming_and_Coding
🚀 Coding Wisdom #120: The Art of Problem Solving
Hello, Coding Maestros! 👩💻👨💻
Embark on a journey of problem-solving, where the code becomes a canvas and you, the artist! 🎨✨
🔍 The Problem-Solving Mindset:
1. Understand the Problem:
- Break it down into smaller parts.
- Clearly define the input, output, and constraints.
2. Explore Strategies:
- Consider different approaches.
- Think about time and space complexity.
3. Start with Pseudocode:
- Draft a high-level plan before diving into code.
- Ensure your logic aligns with the problem.
🌐 Unique Code Challenge: Rotate Array Elements
Explore a unique solution to rotating array elements. Understand the logic and adapt it to different scenarios.
💬 Join the Conversation
@programming_and_coding
Let's elevate our coding wisdom together! 🚀💬 #ProblemSolving #CodingWisdom #CodeChallenge
Hello, Coding Maestros! 👩💻👨💻
Embark on a journey of problem-solving, where the code becomes a canvas and you, the artist! 🎨✨
🔍 The Problem-Solving Mindset:
1. Understand the Problem:
- Break it down into smaller parts.
- Clearly define the input, output, and constraints.
2. Explore Strategies:
- Consider different approaches.
- Think about time and space complexity.
3. Start with Pseudocode:
- Draft a high-level plan before diving into code.
- Ensure your logic aligns with the problem.
🌐 Unique Code Challenge: Rotate Array Elements
#include <stdio.h>💡 Insight:
void rotateArray(int arr[], int n, int k) {
for (int i = 0; i < k; i++) {
int temp = arr[0];
for (int j = 0; j < n - 1; j++) {
arr[j] = arr[j + 1];
}
arr[n - 1] = temp;
}
}
int main() {
int array[] = {1, 2, 3, 4, 5};
int n = sizeof(array) / sizeof(array[0]);
int k = 2;
rotateArray(array, n, k);
printf("Array after rotating %d times:\n", k);
for (int i = 0; i < n; i++) {
printf("%d ", array[i]);
}
return 0;
}
Explore a unique solution to rotating array elements. Understand the logic and adapt it to different scenarios.
💬 Join the Conversation
@programming_and_coding
Let's elevate our coding wisdom together! 🚀💬 #ProblemSolving #CodingWisdom #CodeChallenge
🚀 Coding Odyssey #121: Unleash Your Creativity in Binary!
Hello, Future Code Trailblazers! 👩💻👨💻
Embark on a journey beyond code – dive into the mesmerizing world of binary art! 🌌✨
💻 Binary Art: Where Logic Meets Creativity
Ever thought of expressing your artistic side through code? Let's create a binary masterpiece using simple C code!
- Each '0' or '1' represents a pixel in our binary canvas.
- Customize the binary string to create your unique art!
🤔 How to Contribute:
1. Run the code and admire your binary creation.
2. Share your artistic binary strings or variations in the comments!
💬 Spread the Binary Magic:
Invite friends and coding enthusiasts to join the binary art revolution! 🚀💬
Explore more coding wonders on [Telegram] :
@programming_and_coding
Let's redefine coding as an art form together! #BinaryArt #CodeCreativity #TechInnovation
Hello, Future Code Trailblazers! 👩💻👨💻
Embark on a journey beyond code – dive into the mesmerizing world of binary art! 🌌✨
💻 Binary Art: Where Logic Meets Creativity
Ever thought of expressing your artistic side through code? Let's create a binary masterpiece using simple C code!
#include <stdio.h>🌈 Binary Art Inspiration:
void printBinaryArt() {
char binaryArt[] = "01001000 01100101 01101100 01101100 01101111 00101100 "
"00100000 01000011 01101111 01100100 01100101 01110010 01110011 00101001";
int i = 0;
while (binaryArt[i] != '\0') {
if (binaryArt[i] == '0') {
printf("◻️");
} else if (binaryArt[i] == '1') {
printf("◼️");
} else if (binaryArt[i] == ' ') {
printf(" "); // Space between characters
}
i++;
}
}
int main() {
printBinaryArt();
return 0;
}
- Each '0' or '1' represents a pixel in our binary canvas.
- Customize the binary string to create your unique art!
🤔 How to Contribute:
1. Run the code and admire your binary creation.
2. Share your artistic binary strings or variations in the comments!
💬 Spread the Binary Magic:
Invite friends and coding enthusiasts to join the binary art revolution! 🚀💬
Explore more coding wonders on [Telegram] :
@programming_and_coding
Let's redefine coding as an art form together! #BinaryArt #CodeCreativity #TechInnovation