C Program to Convert Temperature from Fahrenheit to Celsius||Fahrenheit to Celsius Code #programming

preview_player
Показать описание
In this video we will learn how to convert temperature from degree Fahrenheit which in entered by the user to Celsius in C programming language.

#programming #cprogramming #coding #code

If you like this video, give it a thumbs up..& also do let me know about your thoughts through the comment section.

Subscribe if you want to & click the bell icon to get the notifications.

how to convert fahrenheit to celsius,
how to convert temperature from fahrenheit to celsius in c,
convert fahrenheit to celsius in c,
how to convert fahrenheit to celsius in c,
c program to convert fahrenheit to celsius,
fahrenheit to celsius in c,
c code to convert fahrenheit to celsius,
fahrenheit to celsius conversion in c,
convert degree fahrenheit to celsius c program,
simple c program to convert fahrenheit to fahrenheit
Рекомендации по теме
Комментарии
Автор

def print_pattern(num_lines):
for i in range(num_lines, 0, -1):
print("*" * i)

if __name__ == "__main__":
try:
num_lines = int(input("Enter the number of lines: "))
print_pattern(num_lines)
except ValueError:
print("Invalid input. Please enter a valid integer.")

saptarshiroy
Автор

def calculate_F(x):
if x <= 10:
return 3 * x ** 2 + 5
elif x <= 20:
return 5 * x
else:
return 2 * x ** 2 - x + 9

# Input value of x
try:
x = float(input("Enter the value of x: "))
result = calculate_F(x)
print(f"The value of F({x}) is: {result}")
except ValueError:
print("Invalid input. Please enter a valid numerical value for x.")

saptarshiroy
Автор

def find_largest_number(num1, num2, num3):
if num1 >= num2:
if num1 >= num3:
return num1
else:
return num3
else:
if num2 >= num3:
return num2
else:
return num3

# Input three numbers
try:
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))

largest_number = find_largest_number(num1, num2, num3)
print(f"The largest number among {num1}, {num2}, and {num3} is: {largest_number}")
except ValueError:
print("Invalid input. Please enter valid numerical values.")

saptarshiroy
Автор

#include <stdio.h>

#define MAX_ROWS 100
#define MAX_COLS 100

int main() {
int rows1, cols1, rows2, cols2;

printf("Enter the number of rows for matrix 1: ");
scanf("%d", &rows1);

printf("Enter the number of columns for matrix 1: ");
scanf("%d", &cols1);

printf("Enter the number of rows for matrix 2: ");
scanf("%d", &rows2);

printf("Enter the number of columns for matrix 2: ");
scanf("%d", &cols2);

if (cols1 != rows2) {
printf("Error: The number of columns in matrix 1 must be equal to the number of rows in matrix 2.\n");
return 1;
}

int matrix1[MAX_ROWS][MAX_COLS], matrix2[MAX_ROWS][MAX_COLS], result[MAX_ROWS][MAX_COLS];

printf("Enter the elements of matrix 1:\n");
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols1; j++) {
scanf("%d", &matrix1[i][j]);
}
}

printf("Enter the elements of matrix 2:\n");
for (int i = 0; i < rows2; i++) {
for (int j = 0; j < cols2; j++) {
scanf("%d", &matrix2[i][j]);
}
}

// Perform matrix multiplication
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols2; j++) {
result[i][j] = 0;
for (int k = 0; k < cols1; k++) {
result[i][j] += matrix1[i][k] * matrix2[k][j];
}
}
}

printf("Resultant matrix after multiplication:\n");
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols2; j++) {
printf("%d ", result[i][j]);
}
printf("\n");
}

return 0;
}

saptarshiroy
Автор

#include <stdio.h>
#include <stdlib.h>

struct Node {
int data;
struct Node* next;
};

struct Node* createNode(int data) {
struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
newNode->data = data;
newNode->next = NULL;
return newNode;
}

void displayList(struct Node* head) {
struct Node* current = head;
while (current != NULL) {
printf("%d -> ", current->data);
current = current->next;
}
printf("NULL\n");
}

struct Node* addAtBeginning(struct Node* head, int data) {
struct Node* newNode = createNode(data);
newNode->next = head;
return newNode;
}

struct Node* addAtEnd(struct Node* head, int data) {
struct Node* newNode = createNode(data);
if (head == NULL) {
return newNode;
}
struct Node* current = head;
while (current->next != NULL) {
current = current->next;
}
current->next = newNode;
return head;
}

struct Node* addAfterNode(struct Node* head, int data, int target) {
struct Node* newNode = createNode(data);
struct Node* current = head;
while (current != NULL && current->data != target) {
current = current->next;
}
if (current == NULL) {
printf("Target node not found in the list.\n");
free(newNode);
return head;
}
newNode->next = current->next;
current->next = newNode;
return head;
}

struct Node* addBeforeNode(struct Node* head, int data, int target) {
struct Node* newNode = createNode(data);
if (head == NULL) {
printf("List is empty.\n");
free(newNode);
return head;
}
if (head->data == target) {
newNode->next = head;
return newNode;
}
struct Node* current = head;
while (current->next != NULL && current->next->data != target) {
current = current->next;
}
if (current->next == NULL) {
printf("Target node not found in the list.\n");
free(newNode);
return head;
}
newNode->next = current->next;
current->next = newNode;
return head;
}

struct Node* deleteFromBeginning(struct Node* head) {
if (head == NULL) {
printf("List is empty.\n");
return NULL;
}
struct Node* temp = head;
head = head->next;
free(temp);
return head;
}

struct Node* deleteFromEnd(struct Node* head) {
if (head == NULL) {
printf("List is empty.\n");
return NULL;
}
if (head->next == NULL) {
free(head);
return NULL;
}
struct Node* current = head;
while (current->next->next != NULL) {
current = current->next;
}
free(current->next);
current->next = NULL;
return head;
}

struct Node* deleteAfterNode(struct Node* head, int target) {
if (head == NULL) {
printf("List is empty.\n");
return NULL;
}
struct Node* current = head;
while (current != NULL && current->data != target) {
current = current->next;
}
if (current == NULL) {
printf("Target node not found in the list.\n");
return head;
}
if (current->next == NULL) {
printf("No node exists after the target node.\n");
return head;
}
struct Node* temp = current->next;
current->next = current->next->next;
free(temp);
return head;
}

int main() {
struct Node* head = NULL;
int choice, data, target;

do {
printf("1. Add at beginning\n");
printf("2. Add at end\n");
printf("3. Add after a node\n");
printf("4. Add before a node\n");
printf("5. Delete from beginning\n");
printf("6. Delete from end\n");
printf("7. Delete after a node\n");
printf("8. Display list\n");
printf("0. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

switch (choice) {
case 1:
printf("Enter data to add at the beginning: ");
scanf("%d", &data);
head = addAtBeginning(head, data);
break;
case 2:
printf("Enter data to add at the end: ");
scanf("%d", &data);
head = addAtEnd(head, data);
break;
case 3:
printf("Enter data to add: ");
scanf("%d", &data);
printf("Enter the target node after which to add: ");
scanf("%d", &target);
head = addAfterNode(head, data, target);
break;
case 4:
printf("Enter data to add: ");
scanf("%d", &data);
printf("Enter the target node before which to add: ");
scanf("%d", &target);
head = addBeforeNode(head, data, target);
break;
case 5:
head = deleteFromBeginning(head);
break;
case 6:
head = deleteFromEnd(head);
break;
case 7:
printf("Enter the target node after which to delete: ");
scanf("%d", &target);
head = deleteAfterNode(head, target);
break;
case 8:
displayList(head);
break;
case 0:
printf("Exiting...\n");
break;
default:
printf("Invalid choice. Try again.\n");
}
} while (choice != 0);

// Free the memory allocated for the linked list before exiting
struct Node* current = head;
while (current != NULL) {
struct Node* temp = current;
current = current->next;
free(temp);
}

return 0;
}

saptarshiroy
Автор

def count_vowels(word):
vowels = "aeiouAEIOU"
return sum(1 for char in word if char in vowels)

def
words = sentence.split()
words_with_vowels = [(word, count_vowels(word)) for word in words]
sorted_words = sorted(words_with_vowels, key=lambda x: x[0].lower())

for word, num_vowels in sorted_words:
print(f"{word}, {num_vowels}")

# Input sentence
try:
input_sentence = input("Enter a sentence: ")
print("OUTPUT:")

except Exception as e:
print("Error:", e)

saptarshiroy
Автор

#include <stdio.h>
#include <stdlib.h>

struct Node {
int data;
struct Node* next;
};

struct Node* createNode(int data) {
struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
newNode->data = data;
newNode->next = NULL;
return newNode;
}

struct Node* addToEnd(struct Node* head, int data) {
struct Node* newNode = createNode(data);

if (head == NULL) {
newNode->next = newNode;
return newNode;
}

struct Node* current = head;
while (current->next != head) {
current = current->next;
}
current->next = newNode;
newNode->next = head;

return head;
}

struct Node* addToBeginning(struct Node* head, int data) {
struct Node* newNode = createNode(data);

if (head == NULL) {
newNode->next = newNode;
return newNode;
}

struct Node* current = head;
while (current->next != head) {
current = current->next;
}
current->next = newNode;
newNode->next = head;

return newNode;
}

struct Node* addToAfter(struct Node* head, int data, int target) {
struct Node* newNode = createNode(data);

if (head == NULL) {
newNode->next = newNode;
return newNode;
}

struct Node* current = head;
while (current->data != target && current->next != head) {
current = current->next;
}

if (current->data == target) {
newNode->next = current->next;
current->next = newNode;
} else {
printf("Node with value %d not found in the list.\n", target);
free(newNode);
}

return head;
}

struct Node* deleteFromBeginning(struct Node* head) {
if (head == NULL) {
printf("The list is empty.\n");
return NULL;
}

struct Node* temp = head;
while (temp->next != head) {
temp = temp->next;
}

if (head == head->next) {
free(head);
return NULL;
}

temp->next = head->next;
free(head);
return temp->next;
}

struct Node* deleteFromEnd(struct Node* head) {
if (head == NULL) {
printf("The list is empty.\n");
return NULL;
}

struct Node* current = head;
struct Node* prev = NULL;
while (current->next != head) {
prev = current;
current = current->next;
}

if (prev == NULL) {
free(head);
return NULL;
}

prev->next = head;
free(current);
return head;
}

struct Node* deleteNode(struct Node* head, int target) {
if (head == NULL) {
printf("The list is empty.\n");
return NULL;
}

struct Node* current = head;
struct Node* prev = NULL;

while (current->data != target && current->next != head) {
prev = current;
current = current->next;
}

if (current->data == target) {
if (current == head) {
return deleteFromBeginning(head);
} else {
prev->next = current->next;
free(current);
return head;
}
} else {
printf("Node with value %d not found in the list.\n", target);
}

return head;
}

void display(struct Node* head) {
if (head == NULL) {
printf("The list is empty.\n");
return;
}

struct Node* current = head;
do {
printf("%d ", current->data);
current = current->next;
} while (current != head);
printf("\n");
}

int main() {
struct Node* head = NULL;
int choice, data, target;

do {
printf("\n1. Add to end\n");
printf("2. Add to beginning\n");
printf("3. Add after a node\n");
printf("4. Delete from beginning\n");
printf("5. Delete from end\n");
printf("6. Delete a node\n");
printf("7. Display\n");
printf("0. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

switch (choice) {
case 1:
printf("Enter the data to add: ");
scanf("%d", &data);
head = addToEnd(head, data);
break;
case 2:
printf("Enter the data to add: ");
scanf("%d", &data);
head = addToBeginning(head, data);
break;
case 3:
printf("Enter the data to add: ");
scanf("%d", &data);
printf("Enter the target node value: ");
scanf("%d", &target);
head = addToAfter(head, data, target);
break;
case 4:
head = deleteFromBeginning(head);
break;
case 5:
head = deleteFromEnd(head);
break;
case 6:
printf("Enter the value of the node to delete: ");
scanf("%d", &target);
head = deleteNode(head, target);
break;
case 7:
display(head);
break;
case 0:
printf("Exiting...\n");
break;
default:
printf("Invalid choice. Try again.\n");
}
} while (choice != 0);

return 0;
}

saptarshiroy
join shbcf.ru