Separate Even and Odd Numbers in an Array Using For Loop in C

Bhanu Priya
Updated on 24-Mar-2021 13:18:59

2K+ Views

An array is a group of related data items that are stored with single name.For example, int student[30]; //student is an array name that holds 30 collection of data items with a single variable nameOperations of arraySearching − It is used to find whether particular element is present or notSorting − It helps in arranging the elements in an array either in ascending or descending order.Traversing − It processes every element in an array sequentially.Inserting − It helps in inserting the elements in an array.Deleting − It helps in deleting an element in an array.The logic to find even numbers ... Read More

Difference Between Checked and Unchecked Exception in Java

AmitDiwan
Updated on 24-Mar-2021 13:17:47

14K+ Views

In this post, we will understand the difference between checked and unchecked exceptions in Java.Checked ExceptionsThey occur at compile time.The compiler checks for a checked exception.These exceptions can be handled at the compilation time.It is a sub-class of the exception class.The JVM requires that the exception be caught and handled.Example of Checked exception- ‘File Not Found Exception’Unchecked ExceptionsThese exceptions occur at runtime.The compiler doesn’t check for these kinds of exceptions.These kinds of exceptions can’t be caught or handled during compilation time.This is because the exceptions are generated due to the mistakes in the program.These are not a part of the ... Read More

Perform Arithmetic Operations on Two-Dimensional Array in C

Bhanu Priya
Updated on 24-Mar-2021 13:17:01

4K+ Views

An array is a group of related data items that are stored with single name.For example, int student[30]; //student is an array name that holds 30 collection of data items with a single variable nameOperations of arraySearching − It is used to find whether particular element is present or notSorting − It helps in arranging the elements in an array either in ascending or descending order.Traversing − It processes every element in an array sequentially.Inserting − It helps in inserting the elements in an array.Deleting − It helps in deleting an element in an array.The logic applied to perform arithmetic ... Read More

Difference Between Interface and Abstract Class in Java

AmitDiwan
Updated on 24-Mar-2021 13:13:43

759 Views

In this post, we will understand the difference between abstract class and interface in Java and C#.Abstract ClassIt contains the declaration and definition part.Multiple inheritance can’t be implemented using abstract class.It contains the constructor.It can also contain some static members.It can contain multiple types of access modifiers such as public, private, protected.The performance of an abstract class is very good, because it is quick.It is used to implement the core identity/functionality of a class.A class can use only one abstract class.If many implementations are same, and they have a common behaviour, it is suggested to use an abstract class.Abstract classes ... Read More

Perform Arithmetic Operations on Arrays in C Language

Bhanu Priya
Updated on 24-Mar-2021 13:12:55

4K+ Views

An array is a group of related data items that are stored with single name.For example, int student[30]; //student is an array name that holds 30 collection of data items with a single variable nameOperations of arraySearching − It is used to find whether particular element is present or notSorting − It helps in arranging the elements in an array either in ascending or descending order.Traversing − It processes every element in an array sequentially.Inserting − It helps in inserting the elements in an array.Deleting − It helps in deleting an element in an array.The logic to perform all arithmetic ... Read More

Replace All Occurrences of a Character in a String in C

Bhanu Priya
Updated on 24-Mar-2021 13:12:15

8K+ Views

Enter a string at run time and read a character to replace at console. Then, finally read a new character that has to be placed in place of an old character where ever it occurs inside the string.Program1Following is the C program to replace all occurrence of a character − Live Demo#include #include int main(){    char string[100], ch1, ch2;    int i;    printf("enter a string : ");    gets(string);    printf("enter a character to search : ");    scanf("%c", &ch1);    getchar();    printf("enter a char to replace in place of old : ");    scanf("%c", &ch2);    for(i = 0; i

Find Product of Given Digits Using For Loop in C Language

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

3K+ Views

The user has to enter a number, then divide the given number into individual digits, and finally, find the product of those individual digits using for loop.The logic to find the product of given digits is as follows −for(product = 1; num > 0; num = num / 10){    rem = num % 10;    product = product * rem; }Example1Following is the C program to find the product of digits of a given number by using for loop − Live Demo#include int main(){    int num, rem, product;    printf("enter the number : ");    scanf("%d", & num); ... Read More

Difference Between ref and out in C#

AmitDiwan
Updated on 24-Mar-2021 13:09:58

943 Views

In this post, we will understand the difference between ‘ref’ and ‘out’ in C#.Ref keywordBefore passing the parameters to ‘ref’, they need to be initialized.It is not necessary to initialize the value of the parameter before it returns to the calling method.The data can pass in two directions when the ‘ref’ keyword is used.It is useful when the called method needs to change the value of the parameter that is passed.Out keywordIt is not required to initialize parameters before it is passed to ‘out’.It is required to initialize the value of a parameter before it is returned to the calling ... Read More

Difference Between Delegates and Events in C#

AmitDiwan
Updated on 24-Mar-2021 13:06:37

2K+ Views

In this post, we will understand the difference between delegates and events in C#.DelegateIt can be declared using the ‘delegate’ keyword.It is a function pointer.It holds the reference to one or more methods during runtime.It is an independent keyword.It doesn’t depend on events.It contains the Combine() and Remove() methods that help add methods to the list of invocation.It can be passed as a parameter to a method.The ‘=’ operator can be used to assign a single method.The ‘+=’ operator can be used to assign multiple methods to a delegate.EventIt can be declared using the ‘event’ keyword.It can be defined as ... Read More

Difference Between Packages and Interfaces in Java

AmitDiwan
Updated on 24-Mar-2021 13:06:17

5K+ Views

In this post, we will understand the difference between packages and interfaces in Java.PackagesIt is a group of classes and/or interfaces that are together.It can be created using the "Package" keyword.It can be imported.It can be done using the "import" keyword.Examplepackage package_name; public class class_name {    .    (body of class)    . }InterfacesIt is a group of abstract methods and constants.It can be created using the "Interface" keyword.It can be extended by another interface.It can also be implemented by a class.It can be implemented using the ‘implement’ keyword.Exampleinterface interface_name { variable declaration; ... Read More

Advertisements