Bhanu Priya

Bhanu Priya

1,060 Articles Published

Articles by Bhanu Priya

Page 14 of 106

C program to convert upper case to lower and vice versa by using string concepts

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

Converting upper to lower and lower to upper is generally termed as toggle.Toggle each character means, in a given string, the lower letter is print in upper form and upper case is print in lower letter respectively.ProgramThe C program to convert upper case to lower and lower case to upper is given below −#include #define MAX 100 void toggle(char * string); int main(){    char string[MAX];    printf("enter the string need to be toggle :");    gets(string);    toggle(string);    printf("final string after toggling is:");    printf("%s", string);    return 0; } void toggle(char * string){    int i=0; ...

Read More

How to display the complete text one word per line in C language?

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

First, open the file in write mode. Later on, enter the text until it reaches the End Of File (EOF) i.e. press ctrlZ to close the file.Again, open in reading mode. Then, read words from the file and print each word in a separate line and close the file.The logic we implement to print one word per line is as follows −while ((ch=getc(fp))!=EOF){    if(fp){       char word[100];       while(fscanf(fp, "%s", word)!=EOF) // read words from file{          printf("%s", word); // print each word on separate lines.       }     ...

Read More

C program to sort an array of ten elements in an ascending order

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

An array is a group of related data items that are stored with single name.For example, int student[30];Here, student is an array name which holds 30 collection of data items, with a single variable name.OperationsThe operations of an array are explained below −Searching − It is used to find whether a particular element is present or not.Sorting − Helps in arranging the elements in an array either in ascending or descending order.Traversing − Processing every element in an array, sequentially.Inserting − Helps in inserting the elements in an array.Deleting − Helps in deleting an element in an array.In this program, ...

Read More

C program to display only the lower triangle elements in a 3x3 2D array

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

Let’s take the input of 3x3 matrix, means total 9 elements, in 2D array using keyboard at runtime.With the help of it and for loops, we can display only lower triangle in 3X3 matrix.The logic to print lower triangle elements is as follows −for(i=0;i=2nd index          printf("%d",array[i][j]);       else          printf(" "); //display blank in non lower triangle places    }    printf(""); }ProgramFollowing is the C program to display only the lower triangle elements in a 3x3 2D array −#include int main(){    int array[3][3],i,j;    printf("enter 9 numbers:");    for(i=0;i

Read More

Explain the different sections in C language

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 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

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

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 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 −#include int main(){    unsigned int no, sum;    printf("enter any number:");    scanf("%u", &no);    sum=no%10;   ...

Read More

C program to display the prime numbers in between two intervals

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 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 −#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

C program to handle integer data files using file concepts

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 2K+ 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

Explain about link and definition section in C language

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 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

Explain variable declaration and rules of variables in C language

Bhanu Priya
Bhanu Priya
Updated on 11-Mar-2026 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
Showing 131–140 of 1,060 articles
« Prev 1 12 13 14 15 16 106 Next »
Advertisements