Write a C program to read 3 characters one by one and print the characters in a reverse order.
- Declare three character variables to store the input characters.
- Use the scanf function to read the characters one by one from the user.
- Print the characters in reverse order using the printf function.
- End the program.
Thus the program to read 3 characters one by one and print the characters in a reverse order has been executed successfully.
Write a C program to read A values and check whether A is positive number or not.
- Declare a variable to store the input value A.
- Use the scanf function to read the value of A from the user.
- Check if the value of A is greater than zero.
- If A is greater than zero, print a message indicating that it's a positive number.
- Otherwise, print a message indicating that it's not a positive number. 6.End the program.
Thus the program to read A values and check whether A is positive number or not has been executed successfully.
Write a program to find minimum between two fraction numbers using conditional operator or ternary operator.
- Declare variables to store the two fraction numbers and the result.
- Use the printf function to prompt the user to enter the first fraction number (numerator and denominator separately).
- Use the scanf function to read the numerator and denominator of the first fraction.
- Repeat steps 2 and 3 to get the second fraction from the user.
- Calculate the decimal values of both fractions by dividing the numerators by the denominators.
- Use the conditional (ternary) operator to compare the decimal values and store the minimum value in the result variable.
- Print the minimum value.
Thus the program to find minimum between two fraction numbers using conditional operator or ternary operator has been executed successfully.
Write a C program to check whether the input value is equal to 1 using simple if statement
- Declare a variable to store the input value.
- Use the scanf function to read the input value from the user.
- Use an if statement to check if the input value is equal to 1.
- If the condition in the if statement is true, print a message indicating that the input value is equal to 1.
- Otherwise, print a message indicating that it's not equal to 1.
- End the program.
Thus the program to check whether the input value is equal to 1 using simple if statement has been executed successfully
To write a C program that reads marks of three subjects, calculates the total and percentage, and then determines the division (First, Second, Pass, or Fail) based on the percentage and minimum marks criteria.
- Start
- Declare integer variables m1, m2, m3 for marks, and float variables tot, per.
- Input the marks for three subjects.
- Calculate total marks: tot = m1 + m2 + m3
- Calculate percentage: per = tot / 3
- Display total and percentage.
- Check if all marks are greater than or equal to 40:
- If yes: a. If percentage >= 60: Print “Division = First” b. Else if percentage >= 48: Print “Division = Second” c. Else if percentage >= 36: Print “Division = Pass”
- Else: Print “Division = Fail”
- End
The program successfully takes three subject marks, calculates the total and percentage, and correctly determines the division based on predefined grading logic.