Communication Among Functions in C Language

Bhanu Priya
Updated on 13-Mar-2021 11:45:24

739 Views

Functions communicate among themselves with the help of arguments and return value.Farm of ‘C’ function is as follows −return-datatype function name (argument list){    local variable declarations;    executable statements(s);    return (expression); }For example, void mul (int x, int y){    int p;    p=x*y;    printf("product = %d”, p); }Return values and their typesA function may or may not send back a value to the calling function.It will be done by using the return statementThe return types are void, int, float, char and double.If a function is not returning any value, then its return type is ‘void’.Function nameA ... Read More

Top-Down Design and Structure Chart of Function in C Language

Bhanu Priya
Updated on 13-Mar-2021 11:43:10

2K+ Views

A function is a self-contained block that carries out a specific well defined task.Advantages of functions in C language include −Reusability.The length of the program can be reduced.It is easy to locate and find any faulty function.It facilitates top-down modular programming.Top down design and structure chartsIt is a problem solving method in which a complex problem is solved by splitting into sub problems.Structure chart is a documentation tool that shows the relationships among the sub problems of a problem.The splitting of a problem into its related sub problems is the process of refining an algorithm. For example, performing arithmetic operations ... Read More

How Floats Are Stored in C Compiler

Bhanu Priya
Updated on 13-Mar-2021 11:41:56

854 Views

In C programming language, float is a short term for floating point.Floating point numbers are generally represented in the form of Institute of Electrical and Electronics Engineers (IEEE) format.The IEEE format uses a sign bit, a mantissa and an exponent for representing the power of 2.The sign bit denotes the sign of the number: a 0 represents a positive value and a 1 denotes a negative value.The mantissa represented in binary after converting into its normalized form. After normalization mantissa, the most significant digit is always 1.The exponent is an integer stored in unsigned binary format after adding a positive ... Read More

Print the Range of Numbers Using C Language

Bhanu Priya
Updated on 13-Mar-2021 11:41:01

2K+ Views

ProblemFor given number try to find the range in which that number exists.SolutionHere, we are learning how to find the ranges of a number.The logic that we apply to find range is −lower= (n/10) * 10; /*the arithmetic operators work from left to right*/ upper = lower+10;ExplanationLet number n=45Lower=(42/10)*10 // division returns quotient       =4*10 =40Upper=40+10=50Range − lower-upper − 40-50ExampleFollowing is the C program for printing the range of numbers −#include main(){    int n, lower, upper;    printf("Enter a number:");    scanf("%d", &n);    lower= (n/10) * 10; /*the arithmetic operators work from left to right*/    upper ... Read More

Find Sum of First and Last Digit Using Divide and Modulo Operator in C

Bhanu Priya
Updated on 13-Mar-2021 11:40:17

552 Views

ProblemWhat is the C program to obtain the sum of the first and last digit of the number, if a four-digit number is input through the keyboard?SolutionIn this program, we are taking a four-digit number at run time and trying to find the sum of first and last digit of that four-digit number by using the logic −a=n%10; b=n/1000; result = a + b;Let’s apply this logic to find sum of first and last digit of four-digit number −ExampleFollowing is the C program for finding sum of first and last digit by using divide and modulo operator −#include main(){   ... Read More

Explain feof Function in C Language with a Program

Bhanu Priya
Updated on 13-Mar-2021 11:18:45

463 Views

ProblemHow the C compiler detect that the file was reached the end for while reading? Explain with a program.Solutionfeof() is a file handling function in C language, which is used to find end of a file.The logic we used for finding end of file is as follows −fp = fopen ("number.txt", "r"); //open a file printf ("file content is"); for (i=0;i

Uniform Variable Syntax in PHP 7

Urmila Samariya
Updated on 13-Mar-2021 07:13:50

464 Views

In the older versions of PHP, we faced an inconsistency problem. For example: ${$first [‘name’]}. This syntax may create confusion or we can say that the syntax is not consistent. To overcome the inconsistency problem, PHP 7 added the new syntax called “Uniform variable syntax”.The uniform variable syntax evaluates the variables from left to right.We need to add the curly brackets to use the uniform variable syntax. For example, echo ${$first[‘name’]};The uniform variable syntax allows the combinations of operators and also it can break the backward compatibility in some expressions wherever older evaluations are used.ExampleLive DemoOutputOutput for the above PHP ... Read More

Unicode Codepoint Escape Syntax in PHP 7

Urmila Samariya
Updated on 13-Mar-2021 07:11:29

646 Views

PHP 7 takes a Unicode codepoint in hexadecimal form as input and produces the outputs in UTF-8 character format within a double-quoted string. It could be any combination of hexadecimal digits, 2, 4, 6, and above. We can write Unicode characters by using a double-quoted or here docstring, without calling a function. Leading zero is optional in any hexadecimal form. UTF-8 Character Note: We can construct the full Unicode characters using “\u{xxx}” syntax.Some languages, for example, Hebrew and Arabic are read from right to left instead of left to right. We can reverse the text using the ... Read More

Display Array Structure and Values in PHP 7

Urmila Samariya
Updated on 13-Mar-2021 07:06:12

14K+ Views

An array in PHP is a type of data structure that can store multiple elements of similar data type under a single variable.To display array structure and values in PHP, we can use two functions. We can use var_dump() or print_r() to display the values of an array in human-readable format or to see the output value of the program array.Difference between print_r and var_dumpprint_r: It is used to display the variable information in a human-readable format. Array values will be present in a format so that keys and elements can show. print_r also shows protected and private properties of ... Read More

Exceptions and Errors in PHP 7

Urmila Samariya
Updated on 13-Mar-2021 07:03:46

513 Views

In the earlier versions of PHP, we could handle only exceptions. It was not possible to handle errors. In the case of a Fatal Error, it used to halt the complete application or some part of the application. To overcome this problem, PHP 7 added the throwableinterface to handle both exceptions and errors.Exception: Wherever a fatal and recoverable error occurs, PHP 7 throws an exception instead of halting the complete application or script execution.Error: PHP 7 throwsTypeError, ArithmeticError, ParserError, and AssertionError, but the warnings and notice errors remain unchanged. Using the try/catch block, error instance can be caught, and now, the ... Read More

Advertisements