0% found this document useful (0 votes)
9 views

Untitled Document

The document contains two C programs: one for converting Fahrenheit to Celsius and another for performing increment, decrement, and bitwise operations on two integers. The first program prompts the user for a temperature in Fahrenheit and outputs the equivalent Celsius temperature. The second program takes two integers as input and demonstrates increment, decrement, and various bitwise operations, displaying the results accordingly.

Uploaded by

victorspark8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Untitled Document

The document contains two C programs: one for converting Fahrenheit to Celsius and another for performing increment, decrement, and bitwise operations on two integers. The first program prompts the user for a temperature in Fahrenheit and outputs the equivalent Celsius temperature. The second program takes two integers as input and demonstrates increment, decrement, and various bitwise operations, displaying the results accordingly.

Uploaded by

victorspark8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

NAME: BENJAMIN VICTOR OMEYIMI

MAT NO: PSC2207878


COURSE CODE: CSC312

A C program which converts Fahrenheit readings to Celcius.


#include <stdio.h>

// Function to convert Fahrenheit to Celsius


double fahrenheitToCelsius(double fahrenheit) {
return (fahrenheit - 32) * 5 / 9;
}

int main() {
double fahrenheit, celsius;

// Asking user for input


printf("Enter temperature in Fahrenheit: ");
scanf("%lf", &fahrenheit);

// Conversion
celsius = fahrenheitToCelsius(fahrenheit);

// Display result
printf("Temperature in Celsius: %.2lf\n", celsius);

return 0;
}

A C program to implement increment, decrement and bit wise


Output and code to be printed

#include <stdio.h>

int main() {
int a, b;

// To ask user for input


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

// Increment and Decrement


printf("\nInitial values: a = %d, b = %d\n", a, b);
a++; // Increment a
b--; // Decrement b
printf("After increment and decrement: a = %d, b = %d\n", a, b);

// Bitwise Operations
printf("\nBitwise AND (a & b): %d\n", a & b);
printf("Bitwise OR (a | b): %d\n", a | b);
printf("Bitwise XOR (a ^ b): %d\n", a ^ b);
printf("Bitwise Complement of a (~a): %d\n", ~a);
printf("Bitwise Complement of b (~b): %d\n", ~b);
printf("Left shift a (a << 1): %d\n", a << 1);
printf("Right shift b (b >> 1): %d\n", b >> 1);

return 0;
}

You might also like