Mandalika

Mandalika

409 Articles Published

Articles by Mandalika

Page 3 of 41

Differentiate the modulo and division by using C Programming language?

Mandalika
Mandalika
Updated on 15-Mar-2026 6K+ Views

In C programming, the modulo and division operators are fundamental arithmetic operators that work with integers but produce different results from the same operands. Modulo (%) − Returns the remainder after integer division. Division (/) − Returns the quotient (whole number result) of integer division. Syntax result = dividend % divisor; // Modulo operation result = dividend / divisor; // Division operation Example 1: Basic Modulo and Division This example demonstrates the difference between modulo and division operators − #include int main() { ...

Read More

Write a C program to perform 3X3 matrix operations

Mandalika
Mandalika
Updated on 15-Mar-2026 2K+ Views

In C, we can perform various operations on a 3x3 matrix such as calculating row sums, column sums, and diagonal sums. This program demonstrates how to read a 3x3 matrix and compute these basic operations. Syntax int matrix[3][3]; // 3x3 matrix declaration // Row sum: matrix[i][0] + matrix[i][1] + matrix[i][2] // Column sum: matrix[0][j] + matrix[1][j] + matrix[2][j] // Main diagonal: matrix[0][0] + matrix[1][1] + matrix[2][2] // Anti-diagonal: matrix[0][2] + matrix[1][1] + matrix[2][0] Algorithm Step 1: Declare a 3x3 matrix Step 2: Read 9 numbers from user Step 3: Store numbers in ...

Read More

Write a C program of library management system using switch case

Mandalika
Mandalika
Updated on 15-Mar-2026 10K+ Views

A library management system in C allows you to store and manage book information efficiently. This program uses a structure to store book details and implements a menu-driven interface using switch-case statements for different operations. Syntax struct library { char bookname[50]; char author[50]; int noofpages; float price; }; Algorithm Step 1: Declare a structure to hold book data members Step 2: Declare variables for loop control and book counting Step 3: Use switch case to handle different ...

Read More

Write a C program for electing a candidate in Elections by calling functions using Switch case

Mandalika
Mandalika
Updated on 15-Mar-2026 5K+ Views

This C program demonstrates how to create an electronic voting system using functions and switch case statements. The program allows users to cast votes for candidates and view the vote count results. Syntax switch(expression) { case constant1: // statements break; case constant2: // statements break; default: ...

Read More

How to align the output using justificationsin C language?

Mandalika
Mandalika
Updated on 15-Mar-2026 21K+ Views

In C, justifications in printf() statements allow you to format and align output data in various ways. By using width specifiers and alignment flags, you can create well-formatted tables and organized output displays. Syntax printf("%-width format_specifier", value); // Left justification printf("%width format_specifier", value); // Right justification (default) To implement left justification, insert a minus sign (-) before the width value. Without the minus sign, the output is right-justified by default. Example 1: Left Justification with Fixed Width This example demonstrates left justification using %-15s for strings and %-15d ...

Read More

Write C program to calculate balance instalment

Mandalika
Mandalika
Updated on 15-Mar-2026 883 Views

In C programming, calculating loan balance installments involves computing the remaining amount after each monthly payment, considering compound interest. This program demonstrates how to calculate the outstanding balance after making monthly payments on a loan with interest. Syntax balance = principal + (principal * (interest_rate / 100) / 12); remaining_balance = balance - monthly_payment; Formula for Interest Calculation The monthly interest calculation follows this approach − Monthly Interest: principal * ((annual_rate / 100) / 12) Balance with Interest: principal + monthly_interest Remaining Balance: balance_with_interest - monthly_payment Example: Loan Balance Calculator ...

Read More

C program on calculating the amount with tax using assignment operator

Mandalika
Mandalika
Updated on 15-Mar-2026 3K+ Views

In C programming, calculating tax on an amount is a common application of arithmetic and assignment operators. This program demonstrates how to compute the total amount by adding a specific tax percentage to the original amount. Syntax total_amount = original_amount + (original_amount * tax_rate); Problem Write a C Program to enter the amount in dollars and then display the amount by adding 18% as tax. Solution Let's consider the restaurant person adding 18% tax to every bill of the customer. The logic applied to calculate tax is − value = ...

Read More

How to calculate the volume of a sphere using C programming language?

Mandalika
Mandalika
Updated on 15-Mar-2026 7K+ Views

The volume of a sphere is the amount of space enclosed within the sphere. In C programming, we can calculate this using the mathematical formula for sphere volume. Syntax volume = (4.0/3.0) * π * radius³ Where π (pi) ≈ 3.14159 and radius is the distance from the center to any point on the sphere's surface. Algorithm Step 1: Enter radius of sphere at runtime Step 2: Apply the formula to variable Volume = (4/3) * π * radius³ Step 3: Print the volume ...

Read More

What is the purpose and usage of "FOR UPDATE OF" clause in a COBOL-DB2 program

Mandalika
Mandalika
Updated on 01-Dec-2020 5K+ Views

Problem: What is the purpose of the "FOR UPDATE OF" clause in a cursor? What will happen if we fire an UPDATE statement without using this clause in a COBOL-DB2 program?SolutionThe “FOR UPDATE OF” clause is given in the cursor declaration and it is used when we want to update the table. All the columns which need to be updated should be given in the cursor declaration.The “FOR UPDATE OF” clause will place the exclusive lock on all the qualifying rows once the cursor is open. We can also update the table without using “FOR UPDATE CLAUSE” but in that ...

Read More

What is update operation on the cursor having JOIN between 2 tables?

Mandalika
Mandalika
Updated on 01-Dec-2020 829 Views

Problem: Is it possible to update a CURSOR in which we have used JOIN on 2 tables ORDERS and TRANSACTIONS? Why or why not? How can we proceed to UPDATE any of these tables?SolutionWhenever we use JOIN in a cursor on two or more tables (ORDERS and TRANSACTIONS in this case) a temporary table is generated in the virtual memory. However, since this is a temporary table we can fetch data from this table but it is not possible to update this table.If we want to update any of the tables used in the JOIN then we have to declare ...

Read More
Showing 21–30 of 409 articles
« Prev 1 2 3 4 5 41 Next »
Advertisements