Podcast
Questions and Answers
What is the purpose of the first experiment listed in the index?
What is the purpose of the first experiment listed in the index?
Which of the following data types is NOT mentioned in the experiment related to I/O statements?
Which of the following data types is NOT mentioned in the experiment related to I/O statements?
Which algorithm step comes directly after declaring variables in the first experiment?
Which algorithm step comes directly after declaring variables in the first experiment?
In how many experiments are functions utilized according to the index?
In how many experiments are functions utilized according to the index?
Signup and view all the answers
Which experiment is directly related to analyzing numerical properties of a number?
Which experiment is directly related to analyzing numerical properties of a number?
Signup and view all the answers
What concept does the 'Towers of Hanoi using Recursion' experiment primarily illustrate?
What concept does the 'Towers of Hanoi using Recursion' experiment primarily illustrate?
Signup and view all the answers
What task is performed in the experiment 'Find the Length of the string without using library function'?
What task is performed in the experiment 'Find the Length of the string without using library function'?
Signup and view all the answers
Which of the following operations is related to handling data in structured formats?
Which of the following operations is related to handling data in structured formats?
Signup and view all the answers
What will happen if the divisor in the division operation is zero?
What will happen if the divisor in the division operation is zero?
Signup and view all the answers
What is the purpose of the case labeled '5' in the switch statement?
What is the purpose of the case labeled '5' in the switch statement?
Signup and view all the answers
How does the program determine if a number is invalid?
How does the program determine if a number is invalid?
Signup and view all the answers
In the multiplication case of the switch statement, how are the numbers read?
In the multiplication case of the switch statement, how are the numbers read?
Signup and view all the answers
Which of the following statements about the algorithm for checking an Armstrong number is true?
Which of the following statements about the algorithm for checking an Armstrong number is true?
Signup and view all the answers
What is the output when the input number is 0 in the first program?
What is the output when the input number is 0 in the first program?
Signup and view all the answers
What does the if statement in the second program check?
What does the if statement in the second program check?
Signup and view all the answers
Which of the following is true about the nested if-else statement in the program for three numbers?
Which of the following is true about the nested if-else statement in the program for three numbers?
Signup and view all the answers
What would be printed if x is 5 and y is 5 in the second program?
What would be printed if x is 5 and y is 5 in the second program?
Signup and view all the answers
If the user enters -10 in the first program, what will the output be?
If the user enters -10 in the first program, what will the output be?
Signup and view all the answers
In the second program, what condition leads to the output 'y is Greater'?
In the second program, what condition leads to the output 'y is Greater'?
Signup and view all the answers
What is the main purpose of the programs described?
What is the main purpose of the programs described?
Signup and view all the answers
What is the last thing executed in both programs?
What is the last thing executed in both programs?
Signup and view all the answers
What data type is used to store the integer value in the given C program?
What data type is used to store the integer value in the given C program?
Signup and view all the answers
Which formula is used to calculate the area of a triangle in the provided program?
Which formula is used to calculate the area of a triangle in the provided program?
Signup and view all the answers
What will be the output when the user enters '0' for the integer input in the program checking for positive, negative, or zero?
What will be the output when the user enters '0' for the integer input in the program checking for positive, negative, or zero?
Signup and view all the answers
Which statement correctly describes the input for the sides of the triangle in the program calculating the area?
Which statement correctly describes the input for the sides of the triangle in the program calculating the area?
Signup and view all the answers
In the triangle area calculation program, what type of value does 's' represent?
In the triangle area calculation program, what type of value does 's' represent?
Signup and view all the answers
What is a common mistake when trying to input a string into the 'svar' variable in the I/O program?
What is a common mistake when trying to input a string into the 'svar' variable in the I/O program?
Signup and view all the answers
What should be included in the C program to perform sqrt calculations?
What should be included in the C program to perform sqrt calculations?
Signup and view all the answers
Which of the following best describes the control flow used to check if a number is positive, negative, or zero?
Which of the following best describes the control flow used to check if a number is positive, negative, or zero?
Signup and view all the answers
Which condition indicates a leap year?
Which condition indicates a leap year?
Signup and view all the answers
What will the program output if the input year is 1900?
What will the program output if the input year is 1900?
Signup and view all the answers
In the leap year program, which operator is used to check if the year is even?
In the leap year program, which operator is used to check if the year is even?
Signup and view all the answers
What should the program do if the user selects division and the divisor is zero?
What should the program do if the user selects division and the divisor is zero?
Signup and view all the answers
What is the purpose of the step that checks if the user input for operation corresponds to the defined choices?
What is the purpose of the step that checks if the user input for operation corresponds to the defined choices?
Signup and view all the answers
What data type is used for storing the result of the arithmetic operations in the calculator program?
What data type is used for storing the result of the arithmetic operations in the calculator program?
Signup and view all the answers
Which step is NOT included in the leap year algorithm?
Which step is NOT included in the leap year algorithm?
Signup and view all the answers
Which C function is used to output text to the user?
Which C function is used to output text to the user?
Signup and view all the answers
What is the purpose of the program checking for a three-digit integer?
What is the purpose of the program checking for a three-digit integer?
Signup and view all the answers
In the Armstrong number calculation, what operation is performed to isolate the last digit?
In the Armstrong number calculation, what operation is performed to isolate the last digit?
Signup and view all the answers
What will happen if a number less than 100 or greater than 999 is entered into the Armstrong program?
What will happen if a number less than 100 or greater than 999 is entered into the Armstrong program?
Signup and view all the answers
Which part of the program determines if a number is odd or even?
Which part of the program determines if a number is odd or even?
Signup and view all the answers
What will the output be if the user inputs the number 4 in the even or odd program?
What will the output be if the user inputs the number 4 in the even or odd program?
Signup and view all the answers
What is the output after successfully completing the Armstrong program with the input 153?
What is the output after successfully completing the Armstrong program with the input 153?
Signup and view all the answers
What could be a reason for a user to see 'It is an Odd Number' as output?
What could be a reason for a user to see 'It is an Odd Number' as output?
Signup and view all the answers
Which variable in the Armstrong program keeps track of the calculated result?
Which variable in the Armstrong program keeps track of the calculated result?
Signup and view all the answers
Study Notes
Course Information
- Institution: Sai Ram Engineering College
- Department: Mechanical Engineering
- Batch: 2024-2028
- Semester: First Semester
- Course: Programming in C Laboratory
- Academic Year: 2024-2025
- Course Code: 24ESPL101
Laboratory Experiments
-
Experiment 1: I/O statements and expressions
- Aim: Write a C program to display the values using data types.
- Algorithm:
- Start the program
- Declare variables (int, float, char).
- Get input values for each data type.
- Display the values using
printf()
. - End the program
- Program Code: Includes the necessary header file, declares variables, prompts the user to input integer, float and string values using
printf
, stores the input usingscanf
, prints the respective values usingprintf
.
-
Experiment 2: Programs using decision-making constructs (Positive, negative or zero)
- Aim: Write a C program to check if a number is positive, negative, or zero using an if statement.
- Algorithm:
- Start the program
- Declare an integer variable.
- Get input from the user
- Check if the number is >0, <0, or =0 using if-else statements
- Print the result (POSITIVE, NEGATIVE, or ZERO)
- End the program
- Program: Includes header file, declares and initializes variables. Gets input using
printf
andscanf
. Uses anif-else
ladder structure to check and print appropriate results
-
Experiment 3: Greatest among two numbers
- Aim: Write a C program to find the largest of two numbers using
if-else
. - Algorithm:
- Start the program
- Declare two integer variables.
- Get input for the two numbers from the user.
- Compare the two numbers using
if-else
. - Print the largest number.
- End the program.
- Aim: Write a C program to find the largest of two numbers using
-
Experiment 4: Greatest among three numbers
- Aim: Write a C program to find the largest of three numbers using nested
if-else
statements. - Algorithm:
- Start the program.
- Declare three integer variables (a, b, c).
- Input the three numbers from the user.
- Use nested
if-else
to compare the numbers and determine the largest. - Print the largest number.
- End the program.
- Aim: Write a C program to find the largest of three numbers using nested
-
Experiment 5 : Check if a number is divisible by both 5 and 8
- Aim: Check if an input number is divisible by both 5 & 8 using
else if
ladder. - Algorithm:
- Start the program
- Input a number from the user
- Check if the number is divisible by 5 and 8
- Print appropriate message ('Divisible by both 5 and 8', 'Divisible by 8', 'Divisible by 5', 'Divisible by none')
- End the program
- Aim: Check if an input number is divisible by both 5 & 8 using
-
Experiment 6: Check for leap year
- Aim: Determine if a given year is a leap year.
- Algorithm:
- Input year from the user
- Check if the year is divisible by 4, but not 100, or it is divisible by 400.
- Print message ('Leap year' or 'Not leap year').
-
Experiment 7: Simple Arithmetic Calculator
- Aim: Develop a C program to perform basic calculator operations.
- Algorithm:
- Display a menu (options for addition, subtraction, multiplication, division, and square)
- Prompt user input for operation choice
- Implement appropriate calculations by taking the input 2 numbers, as per choosen operation.
- Display the result.
-
Experiment 8: Find the factorial of a given number
- Aim: Calculate the factorial of a number.
- Algorithm:
- Accept input (integer)
- Check input validation.
- Calculate the factorial using a loop
- Present output: Factorial (of the input)
-
Experiment 9: Find the average of 4 given numbers
- Aim: Compute the average of 4 input numbers.
- Algorithm:
- Take input for 4 numbers
- Calculate the sum
- Calculate the average by dividing the sum of 4 input numbers.
- Present output
-
Experiment 10: Display array elements using two-dimensional arrays
- Aim: Display elements of a 2-dimentional array.
- Algorithm:
- Declare a 2-dimensional array.
- Accept input for the array elements
- Print all elements of the array in a formatted way
-
Experiment 11: Perform swapping using a function
- Aim: Write C program to swap two numbers by using a separate function.
- Algorithm:
- Input two numbers.
- Define a function swap to swap the numbers using pointers
- Call the function swap to swap numbers.
- Display swapped numbers.
-
Experiment 12: Generate Prime Numbers between two intervals using functions
- Aim: Display prime numbers within a specified numeric range.
- Algorithm:
- Accept input for the range (n1 and n2).
- Check if each number within the range is prime.
- Define a function to check primality.
- Present output (list of primes).
-
Experiment 13: Solve Towers of Hanoi using recursion
- Aim: Create a recursive program for the Tower of Hanoi puzzle.
- Algorithm:
- The problem is solved by applying a recursive algorithm. Each step and the required calls to other functions and the basic logic are in the algorithm.
-
Experiment 14: Get the largest element of an array using functions
- Aim: Find and display largest element in an array.
- Algorithm:
- Get size of the array
- Accept array elements.
- Define a function to determine the maximum element.
- Print the result (the maximum value).
-
Experiment 15: Concatenate two strings
- Aim: Append (concatenate) two strings.
- Algorithm:
- Input two strings
- Calculate length of first string
- Copy characters of second string to the end of first string
- Print the output
-
Experiment 16: Find the length of a string
- Aim: Measure the length of a given string.
- Algorithm:
- Get an input string from the user
- Count characters up to the null termination character (
\0
) - Display the string length.
-
Experiment 17: Find the frequency of a character in a string
- Aim: Determine the frequency of a given character in a string
- Algorithm:
- Accepting string and target character
- Comparing target character and all characters of string
- Incrementing count accordingly
- Display result
-
Experiment 18: Store and Display Student Information in a Structure
- Aim: Create a structure of student data and display it.
- Algorithm:
- Declaring a Student structure with fields for name, roll number, and marks.
- Input student data (name, roll number, and marks) using a loop
- Display the filled structure for all students.
-
Experiment 19: Process Student Information using Structure
- Aim: Compute total marks by student, highest subject scores, and highest overall marks.
- Algorithm:
- Creates student structure.
- Accepts student data (name, roll number, marks in 3 subjects)
- Calculates total marks for each student.
- Determines highest marks in each subject and student who achieved it.
- Determines the student with the highest overall marks.
-
Experiment 20: Demonstrate file operations
- Aim: Perform file operations including character, word and lines counting and replacement of a word in the text file.
- Algorithm:
- Open the file for reading.
- Initialization of counters for characters, words, and lines to 0.
- Read all characters one by one
- Count characters, words, and lines based on characters.
- Close the file.
- Open the file in write mode.
- Replace specific words in file content and save.
- Close the file.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz covers various programming experiments related to I/O statements, algorithms, and function utilization. It addresses key concepts such as recursion, data types, and numerical properties. Test your knowledge on different programming tasks and the underlying principles behind them.