Found 26504 Articles for Server Side Programming

Explain the END OF FILE (EOF) with a C Program

Bhanu Priya
Updated on 14-Sep-2023 21:13:13

31K+ Views

The End of the File (EOF) indicates the end of input.After we enter the text, if we press CTRL+Z, the text terminates i.e. it indicates the file reached end nothing to read.AlgorithmRefer to the algorithm given below for EOF.Step 1: Open file in write mode. Step 2: Until character reaches end of the file, write each character in filepointer. Step 3: Close file. Step 4: Again open file in read mode. Step 5: Reading the character from file until fp equals to EOF. Step 5: Print character on console. Step 6: Close file.ExampleFollowing is the C program for End of ... Read More

How to access an array element in C language?

Bhanu Priya
Updated on 08-Mar-2021 10:02:11

7K+ Views

An array is a group of related data items that share a common name. A particular value in an array is identified by using its "index number" or "subscript".The advantage of an array is as follows −The ability to use a single name to represent a collection of items and to refer to an item by specifying the item number enables the user to develop concise and efficient programs.The syntax for declaring array is as follows −datatype array_name [size];For example, float height [50]This declares ‘height’ to be an array containing 50 float elements.int group[10]This declares the ‘group’ as an array ... Read More

What do you mean by buffer in C language?

Bhanu Priya
Updated on 08-Mar-2021 09:50:04

10K+ Views

A temporary storage area is called buffer. All input output (I/O) devices contain I/O buffer.When we try to pass more than the required number of values as input then, the remaining values will automatically hold in the input buffer. This buffer data automatically go to the next input functionality, if it is exists.We have to clear the buffer before the next input is taken in.ExampleFollowing is the C program for buffer −#include void main(){    int a, b;    printf(" Enter a value: ");    scanf("%d", &a);    printf(" Enter b value: ");    scanf("%d", &b);    printf(" a+b=%d ", ... Read More

Explain the custom header files in C language

Bhanu Priya
Updated on 08-Mar-2021 07:20:41

598 Views

ProblemCan the user create his/her own custom header files in the C language? If yes, how can we access the user-defined header files?SolutionYes, the user can create his/her own custom header files in C.It helps you to manage the user-defined methods, global variables, and structures in a separate file, which can be used in different modules.Let’s see an example of how to create and access custom header files −ExampleGiven below is the C program to call an external function named swap in the main.c file.#include #include"swaping.h" //included custom header file void main(){    int a=40;    int b=60;    swaping ... Read More

What are Backslash character constants in C language?

Bhanu Priya
Updated on 08-Mar-2021 07:06:32

5K+ Views

A backslash ( \ ) that allows a visual representation of some nongraphic characters introduces an escape.One of the common escape constants is the newline character ( ).Backslash CharactersThe backslash characters are as follows −CharacterMeaning‘\a’alert‘\b’backspace‘\f’form feed‘’newline‘\t’horizontal tab‘\r’carriage return‘\v’vertical tab‘\’backslash‘\’ ’single quote‘\" ’double quote‘\?’Question markExample programFollowing is the C program for the backslash character constants −Example Live Demo#include #define PI 3.14 float area; void main(){    double r;    r=1.0;    area = PI * r * r;    printf("Area is %d ", area); // /n is used to enter the next statement in newline }OutputArea is 1492442840Read More

Conversion of Hex decimal to integer value using C language

Bhanu Priya
Updated on 08-Mar-2021 07:03:39

8K+ Views

ProblemHow to convert the hexadecimal value to integer value by using the C programming language?Explain the concept.SolutionHexadecimal values represent in 16 symbols 1 to 9 & A to F. Here, A to F decimal equivalent is 10 to 15.ExampleFollowing is the C program for converting hexadecimal to an integer by using functions −#include #include #include int hextodc(char *hex){    int y = 0;    int dec = 0;    int x, i;    for(i = strlen(hex) - 1 ; i >= 0 ; --i)//{       if(hex[i]>='0'&&hex[i]

How to find the number of groupwise missing values in an R data frame?

Nizamuddin Siddiqui
Updated on 05-Mar-2021 07:25:18

309 Views

In data science, we often face the problem of missing values and we need to define a way to replace them with an appropriate value or we can complete remove them. If we want to replace the missing then we also need to know how many missing values are there. Therefore, if we have a data frame with grouping column then finding the number of groupwise missing values can be done with aggregate function as shown in the below examples.Example1Consider the below data frame −Live Demo> Group x df1 df1Output   Group  x 1      A  2 2     ... Read More

How to standardize only numerical columns in an R data frame if categorical columns also exist?

Nizamuddin Siddiqui
Updated on 05-Mar-2021 07:25:01

581 Views

The standardization of a numerical column can be easily done with the help of scale function but if we want to standardize multiple columns of a data frame if categorical columns also exist then mutate_if function of dplyr package will be used. For example, if we have a data frame df then it can be done as df%>%mutate_if(is.numeric, scale)Example1Consider the below data frame −Live Demo> x1 x2 df1 df1Output   x1 x2 1   c  4 2   c  1 3   a  4 4   a  1 5   b  0 6   c  4 7   c  2 8 ... Read More

How to create bar plot in base R with different limits for Y-axis?

Nizamuddin Siddiqui
Updated on 05-Mar-2021 07:24:35

1K+ Views

To create a bar plot in base R with different limits for Y-axis, we can use ylim argument but generally that behaves badly, such as extending the bars below X-axis. Therefore, we need to fix those things. Check out the below example to understand how it can be done.Example> x barplot(x)OutputExample> barplot(x,ylim=c(300,600))OutputExample> barplot(x,ylim=c(300,600),xpd=FALSE)OutputExample> box(bty="l") Output

What do you mean by pointer to a constant in C language?

Bhanu Priya
Updated on 08-Mar-2021 07:00:06

683 Views

The value of the pointer address is constant that means we cannot change the value of the address that is pointed by the pointer.A constant pointer is declared as follows −Data_Type const* Pointer_Name;For example, int const *p// pointer to const integerExampleFollowing is the C program to illustrate a pointer to a constant −#include int main(void){    int var1 = 100;    // pointer to constant integer    const int* ptr = &var1;    //try to modify the value of pointed address    *ptr = 10;    printf("%d", *ptr);    return 0; }OutputWhen the above program is executed, it produces the ... Read More

Advertisements