Bhanu Priya

Bhanu Priya

1,060 Articles Published

Articles by Bhanu Priya

Page 11 of 106

C program to find the sum of arithmetic progression series

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 2K+ Views

An arithmetic progression (A.P.) is a sequence of numbers where each term after the first is obtained by adding a constant value called the common difference. This C program calculates the sum of an A.P. series using the mathematical formula. Syntax Sum of A.P. Series: S_n = n/2 * (2a + (n - 1) * d) nth term of A.P. Series: T_n = a + (n - 1) * d Where: a = first term n = number of terms d = common difference S_n = sum of n terms Example: Calculate ...

Read More

C program to generate an electricity bill

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 10K+ Views

In C, generating an electricity bill involves calculating charges based on different rate slabs depending on units consumed. Higher consumption leads to higher per-unit rates, implementing a progressive billing system commonly used by utility companies. Syntax if (units < slab1_limit) { amount = units * rate1; fixed_charge = charge1; } else if (units

Read More

How to add two complex numbers by passing structure to a function in C language?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 7K+ Views

In C programming, complex numbers can be represented using structures with real and imaginary parts as members. To add two complex numbers, we pass the structure variables to a user-defined function that performs the addition and returns the result. Syntax typedef struct complex { float real; float imag; } complex; complex addition(complex num1, complex num2); Algorithm The following steps outline the process for adding two complex numbers using structures − Step 1: Define a structure with real and imaginary parts Step 2: Declare ...

Read More

What do you mean by static memory allocation in C programming?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 3K+ Views

Static memory allocation in C refers to memory allocation that happens at compile time. The memory size and location are determined before the program runs, and once allocated, the memory cannot be resized during program execution. Static Memory Compile Time Fixed Size Dynamic Memory Runtime Variable Size Memory Allocation Types Examples: Arrays, Local variables, Global variables Examples: malloc(), calloc(), realloc() Syntax ...

Read More

Write a C program to demonstrate post increment and pre increment operators

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 3K+ Views

In C programming, the increment (++) and decrement (--) operators are used to increase or decrease a variable's value by 1. These operators can be applied in two forms: pre-increment/decrement and post-increment/decrement, which behave differently in expressions. Syntax /* Pre-increment/decrement */ ++variable; --variable; /* Post-increment/decrement */ variable++; variable--; Pre-Increment Operator (++variable) In pre-increment, the operator is placed before the operand. The value is first incremented and then the operation is performed on it. For example − z = ++a; // First: a = a + 1, Then: ...

Read More

Write C program using isupper() function

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 258 Views

In C, the isupper() function is used to check if a character is an uppercase letter (A-Z). It is defined in the ctype.h header file and returns a non-zero value if the character is uppercase, otherwise returns 0. Syntax int isupper(int ch); Parameters: ch − The character to be checked (passed as int). Return Value: Non-zero if the character is uppercase, 0 otherwise. Example 1: Counting Uppercase Letters Using isupper() This program counts the total number of uppercase letters in a string using the isupper() function − #include #include ...

Read More

Write a C program using time.h library function

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 410 Views

The time.h library in C provides various functions to work with date and time. This library allows you to get the current system time, format it, and perform time-related calculations. Syntax #include time_t time(time_t *timer); char *strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr); struct tm *localtime(const time_t *timer); Key Functions time() − Returns the current time as seconds since January 1, 1970 (Unix timestamp) strftime() − Formats time into a string according to specified format specifiers localtime() − Converts time_t to local time structure (struct tm) ...

Read More

Write a C program to check the atexit() function

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 599 Views

The atexit() is a function that allows the user to register a function that has to be called when the program terminates normally. These registered functions are called in the reverse order of their registration. It is a predefined function that is included in the stdlib.h header file. Syntax int atexit(void (*function)(void)); Parameters: function − Pointer to a function that takes no parameters and returns no value. Return Value: Returns 0 on success, non-zero on failure. Example 1: Basic Usage This example demonstrates how atexit() calls registered functions in ...

Read More

Calculate interest amount by using formula in C language

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 958 Views

In C programming, calculating interest on deposited amounts is a common financial calculation. This program demonstrates how to compute the final amount after applying continuous compound interest over a specified period. Syntax A = P * exp((r/100) * t) Where: P = Principal amount (initial deposit) r = Annual interest rate (percentage) t = Time period in years A = Final amount after interest Algorithm START Step 1: Declare double variables P, r, t, A, M Step 2: Read principal amount to be deposited Step 3: Read annual interest rate ...

Read More

Explain the functions fread() and fwrite() used in files in C

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 24K+ Views

In C programming, fread() and fwrite() functions are used for binary file operations to read and write entire structures or data blocks at once. These functions are particularly useful when working with structured data like records. Syntax size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); Parameters ptr − Pointer to the memory location to read/write data size − Size of each element in bytes nmemb − Number of elements to read/write stream − File pointer Return Value Both functions ...

Read More
Showing 101–110 of 1,060 articles
« Prev 1 9 10 11 12 13 106 Next »
Advertisements