Programming Articles - Page 1375 of 3366

How to pass entire array as an argument to a function in C language?

Bhanu Priya
Updated on 09-Mar-2021 08:08:41

1K+ Views

ArrayThe array is a group of related items that store with a common name. Following are the two ways of passing arrays as arguments to functions −sending entire array as argument to functionsending individual elements as argument to functionSending entire array as an argument to a functionTo send entire array as argument, just send the array name in the function call.To receive an array, it must be declared in the function header.Example 1#include main (){    void display (int a[5]);    int a[5], i;    clrscr();    printf ("enter 5 elements");    for (i=0; i

What are the scope rules to functions in C programming?

Bhanu Priya
Updated on 09-Mar-2021 08:03:16

594 Views

Local scopeLocal scope specifies that variables defined within the block are visible only in that block and invisible outside the block.Global scopeGlobal scope specifies that variables defined outside the block are visible up to end of the program.Example#include int r= 50; /* global area */ main (){    int p = 30;    printf (“p=%d, r=%d” p, r);    fun (); } fun (){    printf (“r=%d”, r); }Outputp =30, r = 50 r = 50Scope rules related to functionsA Function is a block of statements that performs a particular task.Variables that are declared within the body of a function ... Read More

What are the local and global scope rules in C language?

Bhanu Priya
Updated on 09-Mar-2021 07:27:45

376 Views

Global scopeGlobal scope specifies that variables defined outside the block are visible up to end of the program.Example#include int c= 30; /* global area */ main (){    int a = 10;    printf (“a=%d, c=%d” a, c);    fun (); } fun (){    printf (“c=%d”, c); }Outputa =10, c = 30 c = 30Local scopeLocal scope specifies that variables defined within the block are visible only in that block and invisible outside the block.Variables declared in a block or function (local) are accessible within that block and does not exist outside it.Example#include main (){    int i = ... Read More

What are the different categories of functions in C Programming?

Sindhura Repala
Updated on 21-Jan-2025 16:13:15

31K+ Views

Functions are categorized bases on the presence or absences of arguments and whether they return a value. A user-defined function is one that is defined by the user when writing any program, as opposed to library functions that have predefined definitions. To meet specific requirements, the user must develop their own functions. Such functions must be properly defined by the user. A function is a block of code designed to perform a specific task. It is written once and can be reused multiple times as needed by the programmer. ... Read More

What are the different types of functions in C Programming?

Bhanu Priya
Updated on 09-Mar-2021 07:06:23

14K+ Views

Functions are broadly classified into two types which are as follows −predefined functionsuser defined functionsPredefined (or) library functionsThese functions are already defined in the system libraries.Programmer can reuse the existing code in the system libraries which is helpful to write error free code.User must be aware of syntax of the function.For instance, sqrt() function is available in math.h library and its usage is y= sqrt (x), where x= number must be positive.If x value is 25, i.e., y = sqrt (25) then ‘y’ = 5.In the same way, printf() is available in stdio.h library and clrscr() is available in conio.h ... Read More

How to write a C program to find the roots of a quadratic equation?

Bhanu Priya
Updated on 10-Dec-2024 13:10:44

154K+ Views

Problem Applying the software development method to solve any problem in C Language. Solution Find roots of a quadratic equation, ax2+bx+c. There will be 2 roots for given quadratic equation. Analysis Input − a, b, c values Output − r1, r2 values Procedure $r_{1}=\frac{-b+\sqrt{b^2-4ac}}{2a}$ $r_{2}=\frac{-b-\sqrt{b^2-4ac}}{2a}$ Design (Algorithm) Start Read a, b, c values Compute d = b2 4ac if d > 0 then ... Read More

Difference Between High-Level Language and Low-Level Language

Kiran Kumar Panigrahi
Updated on 13-Sep-2023 15:23:37

36K+ Views

A language is basically a mode of communication, because it is used to share information, ideas, and opinions. In computer systems, programming languages are used by the software developers or programmers to creates applications or software systems. A programming language provides a way of writing computer instructions that are used to perform a specific task. Examples of computer programming languages include C, C++, Java, Python, Ruby, Scala, Perl, C#, Groovy, Dart, etc. Based on the closeness of a programming language to the system hardware (mainly processor), computer programming languages are classified into two categories namely, high-level languages and low-level languages. ... Read More

Difference Between For and Foreach in PHP

AmitDiwan
Updated on 02-Mar-2021 05:08:19

5K+ Views

In this post, we will understand the differences between 'for' and 'foreach' loops in PHP −The 'for' loopIt is an iterative loop that repeats a set of code till a specified condition is reached. It is used to execute a set of code for a specific number of times. Here, the number of times is the iterator variable.Syntax:for( initialization; condition; increment/decrement ) {    // code to iterate and execute }Initialization: It is used to initialize the iterator variables. It also helps execute them one at a time without running the conditional statement at the beginning of the loop's condition.Condition: ... Read More

Difference Between Object and Class in C++

AmitDiwan
Updated on 02-Mar-2021 04:57:52

947 Views

In this post, we will understand the difference between an object and a class with respect to C++ programming language.Classes in C++It is a building block of code in C++ that helps implement object oriented programming.It is a type that is defined by the user.It holds its own data members and member functions.These data members and member functions can be accessed by creating an instance of the class.They can be used to manipulate the variables and can be used to define property to tell how the objects in a class have to act.It can be understood as a blueprint for ... Read More

Difference Between C# and C++

AmitDiwan
Updated on 02-Mar-2021 04:56:56

591 Views

Let us first learn about C# and C++ −C# is a general-purpose object-oriented programming language.It is considered as a pure object-oriented programming language.It is pronounced as 'C sharp'.It was developed by Anders Hejlsberg and his team at Microsoft.Memory Management is done automatically by the garbage collector.It is the language's duty to automatically delete the object once its objective is completed.It is windows specific, i.e. it can't be used on all systems.It doesn't support multiple inheritance.The pointers in C# can only be used in the unsafe mode.It is considered as a high-level language.Once the code is compiled, it gets converted into ... Read More

Advertisements