Pages

Showing posts with label C Functions. Show all posts
Showing posts with label C Functions. Show all posts

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

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;
}

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...