C language basic to Advance
2K subscribers
16 photos
2 videos
69 links
Download Telegram
// 14. Check if a given number is a palindrome or not using a while loop:

#include <stdio.h>

int main() {
int num, originalNum, reversedNum = 0;

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

originalNum = num;

while(num != 0) {
reversedNum = reversedNum * 10 + num % 10;
num /= 10;
}

if(originalNum == reversedNum) {
printf("%d is a palindrome.\n", originalNum);
} else {
printf("%d is not a palindrome.\n", originalNum);
}

return 0;
}
// 15. Convert a decimal number to binary using a while loop:

#include <stdio.h>

int main() {
int num, binary[32], i = 0;

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

while(num > 0) {
binary[i] = num % 2;
num = num / 2;
i++;
}

printf("Binary representation: ");
for(int j = i-1; j >= 0; j--) {
printf("%d", binary[j]);
}
printf("\n");

return 0;
}
👍1
// 16. Convert a binary number to decimal using a while loop:

#include <stdio.h>
#include <math.h>

int main() {
int binary, decimal = 0, base = 1, rem;

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

while(binary > 0) {
rem = binary % 10;
decimal = decimal + rem * base;
binary = binary / 10;
base = base * 2;
}

printf("Decimal representation: %d\n", decimal);

return 0;
}
👍1
// 17. Find the GCD of two numbers using a while loop:

#include <stdio.h>

int main() {
int a, b;

printf("Enter two numbers: ");
scanf("%d %d", &a, &b);

while(a != b) {
if(a > b)
a = a - b;
else
b = b - a;
}

printf("GCD is: %d\n", a);

return 0;
}
// 18. Find the LCM of two numbers using a while loop:

#include <stdio.h>

int main() {
int a, b, max;

printf("Enter two numbers: ");
scanf("%d %d", &a, &b);

max = (a > b) ? a : b;

while(1) {
if(max % a == 0 && max % b == 0) {
printf("LCM is: %d\n", max);
break;
}
max++;
}

return 0;
}
👍2
// 19. Print all Armstrong numbers between 1 and 1000 using a for loop:

#include <stdio.h>
#include <math.h>

int main() {
int num, originalNum, remainder, result, n;

printf("Armstrong numbers between 1 and 1000 are:\n");
for(num = 1; num <= 1000; num++) {
originalNum = num;
result = 0;
n = log10(num) + 1;

while(originalNum != 0) {
remainder = originalNum % 10;
result += pow(remainder, n);
originalNum /= 10;
}

if(result == num) {
printf("%d\n", num);
}
}

return 0;
}
👍6
// 20. Print all perfect numbers between 1 and 1000 using a for loop:

#include <stdio.h>

int main() {
int num, i, sum;

printf("Perfect numbers between 1 and 1000 are:\n");
for(num = 1; num <= 1000; num++) {
sum = 0;

for(i = 1; i <= num / 2; i++) {
if(num % i == 0) {
sum += i;
}
}

if(sum == num && num != 0) {
printf("%d\n", num);
}
}

return 0;
}
👍1
All 20 questions and answers related to c loops 👆👇
https://t.me/C_Codes_pro/184
1. भारतीय संविधान को लिखने का कार्य किसने किया था?
- भारतीय संविधान को प्रेम बिहारी नारायण रायज़ादा ने अंग्रेजी में और वसंत कृष्ण वैद्य ने हिंदी में हाथ से लिखा था।

2. संविधान सभा का अध्यक्ष कौन था?
- .....
More details join: https://t.me/SidsAnalysis/38

Join for daily intrusting knowledge
आप सभी को स्वतंत्रता दिवस की हार्दिक बधाई 🇮🇳🇮🇳
5👍3
Forwarded from BCA MCA Btech CS IT Channel (Siddharth Sharma)
Is There any Way to run Any language code other than javascript in frontend (browser) ?
Anonymous Quiz
80%
Yes
20%
No
In these days rust is getting much popular

1) Because of it's speed of execution.
2) It's full controll on system memory
3) it's ownership model
4) And integration to other languages

So why wait let's join our rust channel
https://t.me/Rust_Codes_Pro
👍72
Jinke pass bhi Groups hain 10 members se 250 members tak ke vo mujhe de sakte hain

(Only telegram groups no newly created)
And don't comment here directly message me

Minimum Price 50 rupye maximum price can be 100 vary based on group

And in special group case it will be more

@Panditsiddharth
Or Call 6389680622
👍4
We have started new Channel.
Is channels me aapko 8000 se lekar 1lack+ salary ke jobs achive karne ke liye kya skills required hoti hain unke bare me batayenge.

Kya kya jaroori hota hai cv, experience, education and knowledge se lekar bahut kuchh

Har ek field jaise accounting, Software development se lekar Har tarah ke work ki skills.

To wait karne ki bajay join karlo👇

@NaukriSkills
Join @LogicBots

For
Getting Updates of our bots
Sujjestion for new bot
Sujjestion for new features

https://t.me/logicBots
1
// Prints Current Time of India
#include <stdio.h>
#include <time.h>

int main() {
    time_t rawtime;
    struct tm *utc, ist;

    // Get current time in seconds since Epoch
    time(&rawtime);

    // Convert to UTC
    utc = gmtime(&rawtime);

    // Add 5 hours 30 minutes to UTC → IST
    ist = *utc;
    ist.tm_hour += 5;
    ist.tm_min  += 30;

    // Normalize (handle overflow like 24+ hours, 60+ minutes)
    mktime(&ist);

    printf("Indian Standard Time (IST): %02d:%02d:%02d\n",
           ist.tm_hour, ist.tm_min, ist.tm_sec);

    printf("Date: %02d-%02d-%04d\n",
           ist.tm_mday, ist.tm_mon + 1, ist.tm_year + 1900);

    return 0;
}

// Run On @C_Group_Pro
// Output: t.me/C_Group_Pro/2683
1
New Bot

@VideoCompress0bot

Direct send your large size video to this bot and it will convert to small size

Warning: Don't send already compressed video or low quality video other wise it will increase those size instead decreasing
This media is not supported in your browser
VIEW IN TELEGRAM
Arduino coding Project for C programmers

@C_Codes_pro
2👏2🥰1