Pages

Thursday, December 19, 2024

C- Palindromic Number Checker

 #include<stdio.h>

int main() {


// Declare the variables for Palindromic Number

int num, originalNum, remainder, result = 0;



printf("Enter an integer: ");

scanf("%d", &num);


originalNum = num; // Store the original number


// Reverse the number

while (num != 0) {

    remainder = num % 10; // Get the reversed number

    result = result * 10 + remainder; // Build the reversed number

    num /= 10; // remove the last digit

}


// Check if the no. is Palindrome is not


if (originalNum == result)

    printf("%d is a Palindromic Number.\n", originalNum);

else

    printf("%d is not a Palindromic Number. \n", originalNum);


return 0;


}


Sunday, December 15, 2024

C Lab- BCA 1st Sem #02

 BCA C-Lab- 2nd Lecture 1st Sem

#include<stdio.h> 
 int main() 

{  int x; printf("Enter a number:- "); 
scanf("%d", &x);  if(x%2==0) { 
// == is for checking if both values are true 
printf("\nThe number is even");

 }
 printf("\nThank you :)");

 return 0; }


Things i learnt:- 

1. "==" is for checking if both values are true.


Dark Mode Notes

Welcome to your notes in dark mode! This style reduces eye strain during nighttime or extended reading.

Here’s an example of a code snippet:

printf("Hello, World!");

Feel free to add more content to make your notes stand out!

This is an example link.

Friday, December 13, 2024

C Lab BCA 1st Semester

 C Lab Lectures Problems/Experiments


Lecture-1:- 

Task:- Convert from Fahrenheit to Celcius Program.

#include <stdio.h>
// Fahrenheit to Celcius = C= 5/9 * (F−32)
int main() { // Declare variables for fahrenheit and celcius float c , f; // User inputs value of Fah Temp printf("Enter Fahrenheit Temp Value:- ");
// Reads the value of fahrenheit scanf("%f", &f );
// Formula c = (5.0/9.0) *(f-32);
// Prints the value of Celcius printf("Temp in Celcius is:- %f", c);
return 0; }
}
Problems I faced:- 

1. i had the formula after float variable was declared so that's why it didn't work at few attempts.


2. 
need to put the formula before it's prints/displays the final value of celcius, other code won't work.

Wednesday, December 11, 2024

C - Language Tips

Tips for Learning C Language Coding  


Best Practices for Using Comments in C

  • Be Descriptive: Always strive to write clear and descriptive comments that explain the purpose, functionality, or reasoning behind the code.

  • Update Regularly: Remember to update comments when you modify the code to ensure they remain accurate and relevant.

  • Avoid Redundancy: Avoid writing comments that only restate the obvious. Comments should provide additional information or insights that are not immediately evident from the code itself.

HackerRank - C Language Course

HackerRank - Resources for 

C Language Practice


~ Functions in C Language:- 

1. Function to Find Maximum of Four Integers in C.

- Picks the greatest number from integers a , b , c or d.
- Max Integer will be displayed on the screen with this coding.

#include <stdio.h>

// Function to find the maximum of four integers

int max_of_four(int a, int b, int c, int d)
{
    // Assume A = Max value
    int max = a;

    if (b > max) {
        max = b; // Update max if b is greater
    }
    if (c > max) {
        max = c; // Update max if c is greater
    }
   
    if (d > max) {
        max = d; // Update max if d is greater
    }
   
    return max; // Return the max value
}

int main() {
 
    int a, b, c, d; // Input four integers
    scanf("%d %d %d %d", &a, &b, &c, &d);

    int ans = max_of_four(a, b, c, d); // Get the maximum value

    printf("%d", ans); // Display the result
   
    return 0;
}

Binary Search in C++ (University Exam Topic) - Review Program

 #include <iostream> using namespace std; int binarySearch(int arr[], int size, int key) {     int si = 0;      int ei = size-1;      ...