Programming in C Laboratory Quiz
44 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

In a simple calculator program, the result of adding two numbers is calculated using ______.

addition

When dividing two numbers, if the second number is ______, an error will occur.

zero

The program checks if a number is an ______ number or not as part of its functionality.

Armstrong

To calculate the square of a number in the program, the formula used is ______ multiplied by itself.

<p>number</p> Signup and view all the answers

In the calculator program, the user is prompted to enter their choice through ______.

<p>input</p> Signup and view all the answers

The academic year for the 24ESPL101 - PROGRAMMING IN C Laboratory is ____.

<p>2024-2025</p> Signup and view all the answers

The first experiment involves using I/O statements and ____.

<p>expressions</p> Signup and view all the answers

One of the experiments focuses on checking for a ____ year.

<p>leap</p> Signup and view all the answers

The algorithm for displaying values using data types starts with 'Start the ____.'

<p>Program</p> Signup and view all the answers

The staff in-charge and head of the department certify the ____ record of the work done.

<p>Bonafide</p> Signup and view all the answers

One of the practices includes finding the ____ of a given number.

<p>factorial</p> Signup and view all the answers

A C program can be written to find the ____ of a character in a string.

<p>frequency</p> Signup and view all the answers

The course includes file operations and managing student information using an ____ of structures.

<p>array</p> Signup and view all the answers

The program checks if a number is positive, negative, or ______.

<p>zero</p> Signup and view all the answers

To check the greatest among two numbers, the program uses an if ______ statement.

<p>else</p> Signup and view all the answers

In the first program, the variable used to hold the user's number is called ______.

<p>num</p> Signup and view all the answers

The variables declared to compare two numbers are ______ and y.

<p>x</p> Signup and view all the answers

The output of the program indicates whether the number is POSITIVE, NEGATIVE, or ______.

<p>ZERO</p> Signup and view all the answers

To check the greatest among three numbers, the program uses ______ if-else statements.

<p>nested</p> Signup and view all the answers

The first step in the algorithm to find the greatest among two numbers is to ______ the program.

<p>start</p> Signup and view all the answers

To input a number, the program uses the ______ function.

<p>scanf</p> Signup and view all the answers

Step 2 Get the ______

<p>year</p> Signup and view all the answers

If the year Modulo 4 equal to 0 and Modulo ______ not equal to 0.

<p>100</p> Signup and view all the answers

Check if the year Modulo ______ equal to 0

<p>400</p> Signup and view all the answers

If YES print ______ year

<p>leap</p> Signup and view all the answers

Step 2 Display the menu with options for ______, subtraction, multiplication, division, and square.

<p>addition</p> Signup and view all the answers

If the user selects ______ (option 1):

<p>addition</p> Signup and view all the answers

If the divisor is not zero, calculate the ______.

<p>quotient</p> Signup and view all the answers

Step 9 ______

<p>End</p> Signup and view all the answers

If a > b go to step ______ Otherwise go to step 5

<p>4</p> Signup and view all the answers

If a > c then print '______ is greatest' Otherwise print c is greatest

<p>a</p> Signup and view all the answers

To write a C program to check a given number is divisible by both 5 and ______ using else if ladder statement.

<p>8</p> Signup and view all the answers

If a%5 == 0 && a%8 == 0 then print 'Divisible by both 5 and ______'

<p>8</p> Signup and view all the answers

Step ______: If a%8 == 0 then print 'Divisible by 8' Otherwise go to step 5

<p>4</p> Signup and view all the answers

Else if a%5 == 0 then print 'Divisible by ______'

<p>5</p> Signup and view all the answers

Thus a C program using decision making constructs to check a given number is ______ by both 5 and 8 has been executed successfully.

<p>divisible</p> Signup and view all the answers

The program checks if a given number is an ______ number.

<p>Armstrong</p> Signup and view all the answers

The user is prompted to enter a three-digit ______.

<p>integer</p> Signup and view all the answers

The formula used to check Armstrong is by calculating the ______ of each digit.

<p>cube</p> Signup and view all the answers

In the second program, if the number is divisible by ______, it is even.

<p>two</p> Signup and view all the answers

The variable ______ is used to check if a number is odd or even.

<p>num</p> Signup and view all the answers

If a number is not divisible by two, it is considered an ______ number.

<p>Odd</p> Signup and view all the answers

The final output confirms whether the input number is an ______ or even.

<p>odd</p> Signup and view all the answers

To find the factorial of a number, a variable named ______ is used.

<p>fact</p> Signup and view all the answers

Flashcards

What is a data type in C?

A data type in C that represents a sequence of characters.

List some examples of Data types in C.

Integer, float, and char are some examples of data types in C, each capable of storing different types of data.

What is an Algorithm?

A set of instructions that tells the computer what to do.

What is a program?

It's a sequence of steps that explains how to solve a programming problem.

Signup and view all the flashcards

What are input statements?

They are used to input data into a program.

Signup and view all the flashcards

What are output statements?

They are used to display results or messages on the screen.

Signup and view all the flashcards

What are expressions?

They help you manipulate data in a program, like performing arithmetic operations.

Signup and view all the flashcards

Explain Variable declaration in C.

You can declare variables of different data types, each capable of storing different types of values.

Signup and view all the flashcards

Integer Variable

A variable that can hold a number and can be used to store and manipulate numeric data.

Signup and view all the flashcards

If-Else Statement

A statement that checks a condition and executes different blocks of code based on the result of the condition.

Signup and view all the flashcards

C Program

A program that reads input from the user, performs calculations, and then displays the results.

Signup and view all the flashcards

Greater Than Operator

An operation used to determine if one number is greater than another.

Signup and view all the flashcards

If Block

A block of code that is executed only if the condition in the if statement is true.

Signup and view all the flashcards

Else Block

A block of code that is executed only if the condition in the if statement is false.

Signup and view all the flashcards

Else If Ladder

A type of if-else statement where multiple conditions are checked in a specific sequence.

Signup and view all the flashcards

Condition

A condition that must be met for a specific code block to execute.

Signup and view all the flashcards

What is a string in C?

A data type in C programming that stores a sequence of characters. It is used to represent text strings.

Signup and view all the flashcards

What is the purpose of the printf() function?

A function in C that displays formatted output to the console. It is used to print messages and values to the user.

Signup and view all the flashcards

What is the purpose of the scanf() function?

A function in C that reads formatted input from the console. It is used to get data from the user, such as numbers or strings.

Signup and view all the flashcards

What is an if statement?

A decision-making construct in C that allows a program to execute different blocks of code based on a condition. It evaluates the condition and executes the code block corresponding to the result.

Signup and view all the flashcards

What is an 'if-else if' statement?

A decision-making construct in C used to check multiple conditions sequentially. It executes the first condition that evaluates to true.

Signup and view all the flashcards

What is an 'else' statement?

A block of code that gets executed when all the previous conditions in an 'if-else if' statement are false.

Signup and view all the flashcards

What is a loop?

A programming construct that allows a program to execute a block of code repeatedly while a certain condition remains true. It is used for tasks that involve looping a certain number of times or until a specific condition is met.

Signup and view all the flashcards

What is nested if-else?

A programming structure that allows you to execute nested blocks of code, meaning one block of code is inside another. This is commonly used for decision-making to further refine conditions.

Signup and view all the flashcards

What is a string?

A data type in C that represents a sequence of characters.

Signup and view all the flashcards

What is a switch statement?

It's a way to create different blocks of code that run only when a specific condition is met. The switch keyword is used to start a switch statement.

Signup and view all the flashcards

What is a newline character?

A special character that indicates the end of the line.

Signup and view all the flashcards

What is the default case?

The code that executes when none of the cases in a switch statement match the input value.

Signup and view all the flashcards

What is a leap year?

A leap year is a year that has 366 days, including an extra day in February (February 29th).

Signup and view all the flashcards

What is the modulo operator?

The modulo operator (%) gives the remainder after division. For example, 10 % 3 = 1 because 10 divided by 3 leaves a remainder of 1.

Signup and view all the flashcards

How to determine a leap year?

A year is a leap year if it is divisible by 4 but not by 100, or if it is divisible by 400.

Signup and view all the flashcards

What is a simple arithmetic calculator?

A program that takes user input and performs operations like addition, subtraction, multiplication, division, and finding the square of a number.

Signup and view all the flashcards

What is a calculator menu?

A menu is a list of options displayed to the user, allowing them to choose the desired operation.

Signup and view all the flashcards

What is a program flowchart?

A program flow chart is a visual representation of the steps involved in a program, using symbols and arrows to indicate the sequence of operations.

Signup and view all the flashcards

What is division by zero?

Division by zero results in an error or undefined value, as it is mathematically impossible. It is important to handle division by zero carefully in programs to avoid errors.

Signup and view all the flashcards

String literal

A sequence of characters enclosed within double quotes. For example, "Hello World!".

Signup and view all the flashcards

String variable (in C)

A variable that can store a string of characters, allowing you to manipulate and change text within your program. For example, char name[10] = "John"; declares a character array named name and assigns it the string "John".

Signup and view all the flashcards

Armstrong Number Checker

A program that takes a number as input and determines if it's an Armstrong number. An Armstrong number is a number that is equal to the sum of the cubes of its digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153.

Signup and view all the flashcards

Odd or Even Checker

A program that takes a number as input and determines if it's even or odd. This is done by checking the remainder when the number is divided by 2. If the remainder is 0, the number is even; if it's 1, the number is odd.

Signup and view all the flashcards

Factorial Calculator

A program that calculates the factorial of a given number. The factorial of a number is the product of all positive integers less than or equal to that number. For example, 5! (5 factorial) is 5 * 4 * 3 * 2 * 1 = 120.

Signup and view all the flashcards

C Programming

A way to write a program in the C programming language. It involves using specific keywords, syntax, and libraries to create executable instructions for the computer.

Signup and view all the flashcards

Escape Sequences

A special character used to escape certain characters within a string. For example, \n is used to represent a newline character.

Signup and view all the flashcards

Input Function (scanf)

A function in C that allows you to input data from the user. For example, scanf("%d", &num); reads an integer from the user and stores it in the variable num.

Signup and view all the flashcards

Study Notes

Course Information

  • Institution: Sai Ram Engineering College
  • Department: Mechanical Engineering
  • Batch: 2024-2028
  • Semester: First
  • Course: Programming in C Laboratory
  • Academic Year: 2024-2025
  • Course Code: 24ESPL101

Laboratory Experiments

  • Experiment 1: I/O statements and expressions

    • Aim: To write a C program to display values using data types.
    • Algorithm: Start, declare int, float, char variables, get input values, display values, stop.
    • Program: Includes <stdio.h>, declares integer, float, and character variables. Prompts the user to enter integer, float, and string values, reads the input values using scanf, prints the input values using printf.
  • Experiment 2: Evaluate area of a triangle

    • Aim: To evaluate the area of a triangle using the Heron's formula.
    • Algorithm: Start, input sides (a, b, c), calculate semi-perimeter (s), calculate area (area = sqrt(s * (s - a) * (s - b) * (s - c))), print area, stop.
    • Program: Includes <stdio.h> and <math.h>, declares integer variables for sides (a, b, c) and float variables for semi-perimeter (s) and area (area). Prompts the user to enter the values of a, b, and c, reads the input values using scanf, calculates the area using the Heron's formula, and prints the calculated area using printf.
  • Experiment 3: Check positive, negative or zero

    • Aim: To check whether a given number is positive, negative, or zero using if-else statements.
    • Algorithm: Start, input number, check if number > 0 (positive), number < 0 (negative), otherwise (zero), print result, stop.
    • Program: Includes <stdio.h>, declares an integer variable (num), gets input, uses if-else statements to determine whether the number is positive, negative, or zero and prints the result.
  • Experiment 4: Greatest among two numbers

    • Aim: To find the greatest between two numbers using if-else statement.
    • Algorithm: Start, input two numbers (x and y), compare x and y, if x > y print x is greater, else if x < y print y is greater, else print x and y are equal, stop.
    • Program: Includes <stdio.h>, declares integer variables (x and y), gets inputs, uses if-else statements to compare the values and print the largest number.
  • Experiment 5: Greatest among three numbers

    • Aim: To determine the greatest among three numbers using nested if-else.
    • Algorithm: Start, input three numbers (a, b, c), use nested if-else to compare and identify the largest, print result, end.
    • Program: Includes <stdio.h>, declares integer variables (a, b, c), gets inputs, uses nested if-else to compare the values and prints the largest number.
  • Experiment 6: Check divisibility

    • Aim: To check if a number is divisible by 5 or 8, or both, using else if ladder.
    • Algorithm: Input a number, check divisibility by 5, then by 8, print result; end.
    • Program: Includes <stdio.h>, declares integer variable (a), gets input, uses if-else-if ladder to check divisibility rules and prints corresponding results.
  • Experiment 7: Find Factorial

    • Aim: To calculate a factorial of a given number.
    • Algorithm: Start, input number, calculate factorial, display factorial, end.
    • Program: Includes <stdio.h>, declares integer variable (num), long variable (fact), calculate factorial using for loop, display result.
  • Experiment 8: Find Average of 4 numbers

    • Aim: To calculate the average of 4 integers.
    • Algorithm: Input 4 numbers, calculate the sum, divide by 4, print the average, end.
    • Program: Includes <stdio.h>, declares integers for input numbers (num), sum, and average; calculates sum and average.
  • **Experiment 9: Print half pyramid of * **

    • Aim: To print a half pyramid of asterisks.
    • Algorithm: Start, input number of rows, loop for each row, print asterisks increasing each row, end.
    • Program: Includes <stdio.h>, Takes input from user of number of rows, prints based on rows using nested for loops.
  • Experiment 10: Display array elements

    • Aim: To display array elements in a 2D array
    • Algorithm: Declare a two-dimensional array, take input values into the array, and print elements.
    • Program: Includes <stdio.h>, declares 2D integer array, Takes input element in each row/column using nested for loops, print elements in a formatted manner
  • Experiment 11: Perform swapping

    • Aim: To swap two numbers using a function.
    • Algorithm: Start, input two numbers, call a swap function which swaps the numbers, display swapped values, stop.
    • Program: Includes <stdio.h>, declares integer variables a, b and temporary variable for swapping. Takes input from user, calls the function to swap the values, displays result using printf.
  • Experiment 12: Generate prime numbers

    • Aim: To display all prime numbers between two intervals using a function.
    • Algorithm: Input two numbers, loop through the numbers between the intervals using for loop, if prime print number, end.
    • Program: Includes <stdio.h>, declares integer variables for input numbers, use a user defined function to check for prime numbers using for loop.
  • Experiment 13: Solve Towers of Hanoi

    • Aim: To solve Tower of Hanoi using recursion.
    • Algorithm: Start, Use recursion function, execute the function, end.
    • Program: Includes <stdio.h>, has recursive function to move disks from one rod to another via auxiliary rod.
  • Experiment 14: Largest element in an array

    • Aim: To find the largest element in an array using a function.
      • Algorithm: Input size of array and elements using a for loop, call a user-defined function to find largest, print largest element, end.
      • Program: Includes <stdio.h>, takes input, has a user defined function to find largest element.
  • Experiment 15: Concatenate two strings

    • Aim: To concatenate two strings.
      • Algorithm: Get the length of the first string, concatenate the second string to the end, display the concatenated string, end.
      • Program: Includes <stdio.h>, takes two strings as input, calculates length using a while loop. Concatenates them using a for loop, and displays the result.
  • Experiment 16: Find length of string

    • Aim: Find the length of the string without using library function.
    • Algorithm: Input string, count characters until null character is encountered, display the count, end.
      • Program: Includes <stdio.h>, takes string as input, counts characters using while loop, prints the length.
  • Experiment 17: Frequency of a character

    • Aim: To find the frequency of a character in a string.
    • Algorithm: Input String and character, traverse string, count occurrences; display frequency.
    • Program: Includes <stdio.h>, takes strings and character as input, counts using for loop.
  • Experiment 18: Store and display student information in a structure

    • Aim: To store and display student information using a structure.
    • Algorithm: Defines a structure, takes student information as input (name, roll no, marks), stores data, and displays as output.
  • Program: Includes <stdio.h>, defines a structure named "student", takes input data using for loops for multiple students; prints all student data with their roll number.

  • Experiment 19: Process student information

    • Aim: To process and determine total marks, highest subject mark, and highest total mark of students.
    • Algorithm: Input student data, compute total marks, find highest marks in each subject, and the student with the highest overall total marks, display results.
    • Program: Includes <stdio.h>, defines structure, takes inputs for the details of students, computes the total for each student; finds the highest total score for each subject and for all subjects, displays result.
  • Experiment 20: Demonstrate file operations

    • Aim: To demonstrate counting characters, words, and lines in a file and replacing specific words within a file.
    • Algorithm: Open file, compute counts, write buffer overwriting content in the file, display results.
    • Program: Includes <stdio.h>, <stdlib.h>, and <string.h>, functions to count characters, words, and lines, and another function to replace certain words in the file.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

Description

Test your knowledge on various concepts covered in the 24ESPL101 - Programming in C Laboratory. This quiz includes questions about basic operations in a calculator program, I/O statements, and experiments related to number properties. Perfect for students looking to reinforce their understanding of C programming fundamentals.

More Like This

Use Quizgecko on...
Browser
Browser