Bhanu Priya

Bhanu Priya

1,060 Articles Published

Articles by Bhanu Priya

Page 98 of 106

Explain nested switch case in C language

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

ProblemWrite a C program to check the entered password by the user is valid or not based on his/her ID using nested switch case.SolutionThe solution is explained below −In C language, we can write inner switch which is placed in an outer switch.The case values of the inner and outer switch can have common values.RulesAn expression executes to a result.Constants and unique values must be used for case labels.Case labels has to be end with a colon ( : ).A break keyword has to be included in each case.There can be only one default label.We can write nested multiple switch ...

Read More

Explain different types of expressions in C program

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2021 4K+ Views

An expression is a combination of operators and operands which reduces to a single value. An operation is performed on a data item which is called an operand. An operator indicates an operation to be performed on data.For example, z = 3+2*1z = 5Primary expressions − It is an operand which can be a name, a constant or any parenthesized expression. Example − c = a+ (5*b);Postfix expressions − In a postfix expression, the operator will be after the operand. Example − ab+Prefix expressions − n a prefix expression, the operator is before the operand. Example − +abUnary expression − ...

Read More

What are executable statements in C language?

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

A ‘C’ program contains executable statements. A compiler helps to translate the executable statements into machine language.When a user runs the program, he/she machines the language statements which are executed by the compiler.Types of executable statementsThe types of executable statements in C language are as follows −Input – output statementsAssignment statementsInput-output statementsStoring a value into memory is called ‘input operation’.After executing the computations, the results are stored in memory and the results can be displayed to the user by ‘output operation’.All i/o operations are performed using input / output functions.The most common I/O functions are supplied through the preprocessor directive ...

Read More

Explain variable declaration and rules of variables in C language

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

Let us first understand, what is a variable.VariableIt is the name for memory location that may be used to store a data value.A variable may take different values at different times during execution.A variable name may be chosen by the programmer in a meaningful way, so as to reflect its function (or) nature in the program.For example, sum, avg, total etc.Rules for naming variableThe rules for naming a variable are explained below −They must begin with a letter.Maximum length of variable is 31 characters in ANSI standard. But, first eight characters are significant by many compilers.Upper and lowercase characters are ...

Read More

Explain about link and definition section in C language

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2021 5K+ Views

The link and definition sections are called as preprocessor directives. It gives instructions to the compiler to link function from the system library.For example, the definition section defines all the symbolic constants.#includeFor example, #define PI 3.1415The preprocessor directives must start with # symbol.Without link definition the program will not execute for some compilers. It helps the compiler to link the predefined functions from system library.Predefined FunctionsThe predefined functions present in stdio.h are as follows −FunctionDescriptionprintf()Print the character, string, float, integer, octal onto the screen.scanf()Read a character, string, numeric data from keyboard.getc()Reads character from file.gets()Reads line from keyboard.getchar()Reads character from keyboard.puts()Writes ...

Read More

C program to handle integer data files using file concepts

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

In this program, we are trying to sort out the odd numbers and even numbers that are present in one file. Then, we try to write all odd numbers in ODD file and even numbers into EVEN file.Open a file DATA in write mode and write some numbers into the file and later on close it.Again, Open DATA file in read mode.Open ODD file in write mode.Open EVEN file in write mode.Then, perform the operations to check odd and even numbers by using while loop.After that close all files.ExampleFollowing is the C program to handle integer data files using file ...

Read More

What are different pointer operations and problems with pointers in C language?

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

A pointer is a variable whose value is the address of an another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable address.Consider the following statement −int qty = 179;The representation of the variable in memory is as follows −You can declare a pointer as follows −Int *p;It means ‘p’ is a pointer variable that holds the address of another integer variable.Address operator (&) is used to initialize a pointer variable.For Example −int qty = 175; int *p; p= &qty;To access the value of ...

Read More

C program to display the prime numbers in between two intervals

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

Enter two numbers at console during runtime. Then, declare the flag variable which is used to check whether the number is prime or not with the help of for loop condition.Whenever, the flag is zero, it prints the prime number and if flag is one, it exists from the loop.ProgramFollowing is the C program to display the prime numbers in between two intervals − Live Demo#include int main(){    int number1, number2, i, j, flag;    printf("enter the two intervals:");    scanf("%d %d", &number1, &number2);    printf("prime no’s present in between %d and %d:", number1, number2);    for(i=number1+1;i

Read More

Find the sum of first and last digit for a number using C language

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2021 4K+ Views

The sum of first and last digit for a number can be calculated if we use the below mentioned algorithm in C programming language.AlgorithmRefer an algorithm given herewith −START Step 1: Declare no, sum variables of type int Step 2: Read a number at runtime Step 3: Compute sum=no%10 Step 4: While loop no>9    No=no/10 Step 5: Compute sum=sum+no; Step 6: Print sum STOPExampleFollowing is the C program to find the sum of first and last digit for a number − Live Demo#include int main(){    unsigned int no, sum;    printf("enter any number:");    scanf("%u", &no);    sum=no%10; ...

Read More

Explain the different sections in C language

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

C program is defined by set of protocols that are to be followed by a programmer, while writing the code.SectionsThe complete program is divided into different sections, which are as follows −Documentation Section − Here, we can give commands about program like author name, creation or modified date. The information written in between/* */ or // is called as comment line. These lines are not considered by the compiler while executing.Link section − In this section, header files that are required to execute the program are included.Definition section − Here, variables are defined and initialised.Global declaration section − In this ...

Read More
Showing 971–980 of 1,060 articles
« Prev 1 96 97 98 99 100 106 Next »
Advertisements