Bhanu Priya has Published 1606 Articles

Write a C program to compare two strings using strncmp library function

Bhanu Priya

Bhanu Priya

Updated on 06-Mar-2021 07:39:52

Strncmp is a predefined library function present in string.h file, it used to compare two strings and display which string is greater.The strcmp fucntion (String comparison)This function compares 2 strings. It returns the ASCII difference of the first two non– matching characters in both the strings.Syntaxint strcmp (string1, string2);If the ... Read More

Write a C program to read a data from file and display

Bhanu Priya

Bhanu Priya

Updated on 06-Mar-2021 07:36:39

ProblemHow to read a series of items that are present in a file and display the data in columns or tabular form using C ProgrammingSolutionCreate a file in write mode and write some series of information in the file and close it again open and display the series of data ... Read More

Write a C program to find total number of lines in an existing file

Bhanu Priya

Bhanu Priya

Updated on 06-Mar-2021 07:33:00

Open a file in reading mode. If the file exists, then write a code to count the number of lines in a file. If the file does not exist, it displays an error that the file is not there.The file is a collection of records (or) It is a place ... Read More

Write a C program demonstrating examples on pointers

Bhanu Priya

Bhanu Priya

Updated on 06-Mar-2021 07:16:31

A pointer is a variable that stores the address of another variable.Features of PointersPointer saves the memory space.The execution time of a pointer is faster because of direct access to memory location.With the help of pointers, the memory is accessed efficiently, i.e., memory is allocated and deallocated dynamically.Pointers are used ... Read More

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

Bhanu Priya

Bhanu Priya

Updated on 06-Mar-2021 07:10:26

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 ... Read More

Legal and illegal declaration and initializations in C

Bhanu Priya

Bhanu Priya

Updated on 06-Mar-2021 07:02:53

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 ... Read More

Advertisements