Bhanu Priya

Bhanu Priya

1,060 Articles Published

Articles by Bhanu Priya

Page 5 of 106

Explain reference and pointer in C programming?

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

ProblemExplain the concept of reference and pointer in a c programming language using examples.ReferenceIt is the alternate name for the variable that we declared.It can be accessed by using pass by value.It cannot hold the null values.Syntaxdatatype *variablenameFor example, int *a; //a contains the address of int type variable.PointerIt stores the address of variable.We can hold the null values using pointer.It can be access by using pass by reference.No need of initialization while declaring the variable.Syntaxpointer variable= & another variable;Example#include int main(){    int a=2, b=4;    int *p;    printf("add of a=%d", &a);    printf("add of b=%d", &b);   ...

Read More

Explain linear data structure queue in C language

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 860 Views

Data structure is collection of data organized in a structured way. It is divided into two types as explained below −Linear data structure − Data is organized in a linear fashion. For example, arrays, structures, stacks, queues, linked lists.Nonlinear data structure − Data is organized in a hierarchical way. For example, Trees, graphs, sets, tables.QueueIt is a linear data structure, where the insertion is done at rear end and the deletion is done at the front end.The order of queue is FIFO – First In First OutOperationsInsert – Inserting an element into a queue.Delete – Deleting an element from the ...

Read More

What is C unconditional jump statements?

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

C programming language allows jumping from one statement to another. It also supports break, continue, return and go to jump statements.breakIt is a keyword which is used to terminate the loop (or) exit from the block.The control jumps to next statement after the loop (or) block.break is used with for, while, do-while and switch statement.When break is used in nested loops then, only the innermost loop is terminated.The syntax for break statement is as follows −ExampleFollowing is the C program for break statement −#include main( ){    int i;    for (i=1; i

Read More

C program to count a letter repeated in a sentence.

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

ProblemWrite a program to count a letter, which is entered by the user at console. How many times that letter is repeated in a sentence need to be printed on screen by using strlen() function.SolutionThe logics we used to count a letter are as follows −Asking the user to enter a sentence at runtime.printf("Enter a sentence"); gets(str);Asking the user to enter a letter at runtime.printf("Enter a character to check how many times it is repeating"); scanf("%c", &c);The logic to count the letter in a sentence is as follows −for(i=0;i

Read More

Write a C program for guessing the number game.

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

ProblemIn a program a number is already initialized to some constant. Here, we have to ask the user to guess that number which is already in the program. For this, we need to provide some clues for every time the user entering the number.SolutionThe logic that is used to guess the number is as follows −do{    if(num==guess){       flag=0;    } else if(guess

Read More

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

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

Bitwise operators operate on bits (i.e. on binary values of on operand)OperatorDescription&Bitwise AND|Bitwise OR^Bitwise XORRight Shift-One's complementBitwise ANDaba & b000010100111Bitwise ORaba | b000011101111Bitwise XORaba ^ b000011101110ExampleFollowing is the C program for addition and multiplication by 2 with the help of bitwise operators −#include main(){    int a;    printf("Enter a");    scanf("%d",&a);    printf("%d*2=%d ",a,a1); }OutputWhen the above program is executed, it produces the following output −Run 1: Enter a 45 45*2=90 45/2=22 Run 2: Enter a 65 65*2=130 65/2=32

Read More

Explain scope of a variable in C language.

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

Storage classes specify the scope, lifetime and binding of variables.To fully define a variable, one needs to mention not only its ‘type’ but also its storage class.A variable name identifies some physical location within computer memory, where a collection of bits are allocated for storing values of variable.Storage class tells us the following factors −Where the variable is stored (in memory or cpu register)?What will be the initial value of variable, if nothing is initialized?What is the scope of variable (where it can be accessed)?What is the life of a variable?ScopeScope defines the visibility of an object. It defines where ...

Read More

Legal and illegal declaration and initializations in C

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

ProblemMention some of the legal and illegal declarations and initializations while doing C programming?Before discussing the legal and illegal statements let’s see how to declare and initialize the variables in C.Variable declarationFollowing is the syntax of variable declaration −SyntaxDatatype v1, v2, … vn;Where v1, v2, ...vn are names of the variables.For example, int sum;float a, b;Variable can be declared in two ways −local declarationglobal declarationThe ‘local declaration’ is declaring a variable inside the main block and its value is available within that block.The ‘global declaration’ is declaring a variable outside the main block and its value is available throughout the ...

Read More

Write a C program to display the size and offset of structure members

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

ProblemWrite a C program to define the structure and display the size and offsets of member variablesStructure − It is a collection of different datatype variables, grouped together under a single name.General form of structure declarationdatatype member1; struct tagname{    datatype member2;    datatype member n; };Here, struct  - keywordtagname - specifies name of structuremember1, member2 - specifies the data items that make up structure.Examplestruct book{    int pages;    char author [30];    float price; };Structure variablesThere are three ways of declaring structure variables −Method 1struct book{    int pages;    char author[30];    float price; }b;Method 2struct{   ...

Read More

C Program to print all ASCII values.

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 5K+ Views

ProblemPrint the American Standard Code for Information Interchange (ASCII) values of 0 to 255 characters without initializing the character to integer type variable. Simply, use the format specifier.SolutionHere we are writing a program to print only from 65 to 122.If you want to see all ASCII values, in for loop you can write as follows −For(i=0;i

Read More
Showing 41–50 of 1,060 articles
« Prev 1 3 4 5 6 7 106 Next »
Advertisements