Bhanu Priya

Bhanu Priya

1,061 Articles Published

Articles by Bhanu Priya

Page 43 of 107

C program for Addition and Multiplication by 2 using Bitwise Operations.

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

Bitwise operators in C operate directly on bits (binary representation) of operands. They are highly efficient for arithmetic operations like multiplication and division by powers of 2. The left shift () operators can perform these operations faster than traditional arithmetic operators. Syntax // Multiplication by 2 result = number > 1; Bitwise Operators Overview Operator ...

Read More

C program to print area of triangle, square, circle, rectangle and polygon using switch case.

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

This C program calculates the area of different geometric shapes using a switch case statement. The program provides a menu−driven interface where users can select from triangle, square, circle, rectangle, and parallelogram area calculations. Syntax switch (expression) { case constant1: // statements break; case constant2: // statements break; default: ...

Read More

Write a C program for guessing the number game.

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

A number guessing game is a classic programming exercise where the computer has a secret number and the user must guess it. The program provides hints after each guess, telling whether the guess is too high or too low, until the correct number is found. Syntax do { if (guess == secretNumber) { // Correct guess - exit loop } else if (guess < secretNumber) { // Give "too low" hint ...

Read More

C program to count a letter repeated in a sentence.

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

In C programming, counting the frequency of a specific character in a string is a common task. This program prompts the user to enter a sentence and a character, then counts how many times that character appears in the sentence using strlen() function for string length determination. Syntax for(i = 0; i < strlen(string); i++) { if(string[i] == character) { count++; } } Algorithm The logic to count character frequency involves the following steps − Read ...

Read More

What is C unconditional jump statements?

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

C programming language provides unconditional jump statements that allow transferring control from one part of the program to another without evaluating any condition. The four main unconditional jump statements are break, continue, return, and goto. break Statement The break statement is used to terminate loops or exit from switch blocks immediately. When executed, control jumps to the statement following the loop or block. Syntax break; Example The following program demonstrates the break statement in a loop − #include int main() { int i; for (i = 1; i

Read More

What do you mean by odd loops in C language?

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

In C programming language, loops are used to repeat a set of statements. While traditional loops have known iterations, odd loops refer to loops where the number of iterations is unknown or determined by user input during runtime. These are also called indefinite loops. Syntax while (condition) { // statements // update condition based on user input } Understanding Odd Loops Odd loops are characterized by − Unknown number of iterations at compile time Loop termination depends on user input or runtime conditions Often ...

Read More

Explain the conversions of expressions of stacks in C language

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

Stack is a linear data structure where data is inserted and removed only at one end. Stacks are particularly useful for converting expressions between different notations like infix, prefix, and postfix. Stack Operations Before understanding expression conversions, let's review the basic stack operations − Push Operation Inserts an element at the top of the stack − if (top == n-1) printf("Stack overflow"); else { top++; stack[top] = item; } Pop Operation Removes and returns the top element from the stack − ...

Read More

Explain linear data structure queue in C language

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

A queue is a linear data structure that follows the First In First Out (FIFO) principle. In a queue, elements are inserted at the rear end and deleted from the front end, similar to a real-world queue where the first person to join the line is the first to be served. 10 20 30 40 FRONT REAR DELETE ...

Read More

Explain C Error handling functions

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

In C programming, error handling functions are essential for managing errors that occur during file operations. These functions help detect and report errors when reading from or writing to files, ensuring robust and reliable programs. Syntax int ferror(FILE *stream); void perror(const char *s); int feof(FILE *stream); Common File Operation Errors Some common errors in file operations include − Trying to read beyond the end of file Device overflow Trying to open an invalid file Performing invalid operations (e.g., writing to a read-only file) ferror() Function The ferror() function is ...

Read More

Explain putc() and getc() functions of files in C language

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

The putc() and getc() functions in C are used for character-based file input/output operations. These functions allow you to read and write single characters to files, making them useful for processing text files character by character. Syntax int putc(int ch, FILE *fp); int getc(FILE *fp); The putc() Function The putc() function writes a character to a file. It takes two parameters − the character to write and a file pointer. It returns the written character on success or EOF on failure. The getc() Function The getc() function reads a character from a ...

Read More
Showing 421–430 of 1,061 articles
« Prev 1 41 42 43 44 45 107 Next »
Advertisements