Found 1401 Articles for C

System() Function in C/C++

Sunidhi Bansal
Updated on 06-Sep-2023 21:57:43

35K+ Views

Given the task is to show the working of system() in C/C++.The system() function is a part of the C/C++ standard library. It is used to pass the commands that can be executed in the command processor or the terminal of the operating system, and finally returns the command after it has been completed. or should be included to call this function.SyntaxThe syntax is as follows −int system(char command)This function returns zero if the command is executed without any errors.ExampleInput: system(“date”) Output: The current date is: Fri 12/27/2019Explanation − The following example shows how we can use the system ... Read More

strstr() function in C/C++

Sunidhi Bansal
Updated on 20-Jan-2020 07:10:22

551 Views

strstr() function is a predefined function in “string.h” header file which is used for performing string handling. This function is used to find the first occurrence of a substring let’s say str2 in the main string let’s say str1.SyntaxSyntax of strstr() is as follows −char *strstr( char *str1, char *str2);Parameters of strstr() arestr2 is the substring which we wish to search in the main string str1Return value of strstr() isThis function returns the address pointer of the first occurrence of the substring which we are searching if found in the main string, else it will return a null when the ... Read More

Difference between Java and C language

Mahesh Parahar
Updated on 24-Feb-2020 08:06:43

638 Views

Both Java and C are the most popular programming languages in programming world.Due to their various important characteristics and features both of these languages are widely used globally.On the basis of their features following are the important differences between Java and CSr. No.KeyJavaC1IntroducedJava was developed after C as compared on introducing year.It was developed by James Gosling in 1995.On other hand C was introduced before Java and was developed by Dennis M. Ritchie between 1969 and 1973.2TypeJava is a high level language and is more data oriented also known globally as Object-Oriented language.On other hand C is a middle-level language ... Read More

Difference between float and double in C/C++

Mahesh Parahar
Updated on 24-Feb-2020 08:04:39

2K+ Views

As we know that in C/C++ we require float and double data type for the representation of Floating point numbers i.e the numbers which have decimal part with them.Now on the basis of precision provided by both of these data types we can differentiate between both of them.In simple words it could be state that double has 2x more precision as compare than float which means that double data type has double precision than as compare to that of float data type.In terms of number of precision it can be stated as double has 64 bit precision for floating point ... Read More

Difference between Structure and Array in C

Mahesh Parahar
Updated on 25-Feb-2020 07:13:01

7K+ Views

In C both Structure and Array are used as container for data types i.e in both structure and array we can store data and also can perform different operations over them.On the basis of internal implementation following are some basic differences between both.Sr. No.KeyStructureArray1DefinitionStructure can be defined as a data structure used as container which can hold variables of different types.On other hand Array is a type of data structure used as container which can hold variables of same type and do not support multiple data type variables.2Memory AllocationMemory allocation for input data in structure does not necessary to be ... Read More

Difference between strlen() and sizeof() for string in C Program

Mahesh Parahar
Updated on 25-Feb-2020 06:57:24

257 Views

As we know that in programming string can be defined as the collection of characters. Now for the requirement of finding how many characters are being used to create a string, C provides two approaches which are strlen() and sizeof().As mentioned in above point both of these methods are used to find out the length of target operand but on the basis of their internal implementation following are some basic differences between both.Sr. No.Keystrlen()sizeof()1Definitionstrlen() is a predefined function defined in a Header file named string.h in C.On other hand sizeof() is a Unary operator and not a predefined function.2Implementationstrlen is ... Read More

Difference between Structure and Union in C Program

Kiran Kumar Panigrahi
Updated on 28-Jun-2024 00:12:04

28K+ Views

In C, we have containers to hold data of same data type as well as different data types. C provides the concept of Arrays to store data variables of same type; while for storing data of different types, C has the concept of structures and unions. Both Structures and Unions can hold different types of data, but on the basis of their internal implementation, we can find several differences in both of these containers. Read this article to learn more about structures and unions and how they are different from each other. What is Structure in C Program? In C ... Read More

Power of Two in C

Arnab Chakraborty
Updated on 28-Apr-2020 10:28:29

547 Views

Suppose we have a number n. We have to check whether the number is the power of 2 or not. So is n = 16, then the output will be true, if n = 12, it will be false.To solve this we will use logical operations. If we see the numbers that are the power of two then in the binary representation of that number will be the MSb is 1, and all other bits are 0. So if we perform [n AND (n – 1)], this will return 0 if n is the power of 2. If we see ... Read More

Program to print Square inside a Square in C

suresh kumar
Updated on 09-Jan-2020 07:16:17

719 Views

Program DescriptionPrint Square inside a Square as shown belowAlgorithmAccept the number of rows the outer Square to be drawn Display the Outer Square with the number of rows specified by the User. Display another square inside the outer square.Example/* Program to print Square inside Square */ #include int main() {    int r, c, rows;    clrscr();    printf("Enter the Number of rows to draw Square inside a Square: ");    scanf("%d", &rows);    printf("");    for (r = 1; r

Program to print solid and hollow square patterns in C

suresh kumar
Updated on 13-Jul-2020 12:04:35

627 Views

Program DescriptionIn geometry, a square is a regular quadrilateral, which means that it has four equal sides and four equal angles.Solid and Hollow Square will appear as shown belowAlgorithmFor Solid Square −Accept the Number of Rows from the user to draw the Solid Square For each Row, Print * for each Column to draw the Solid SquareFor Hollow Square −Accept the Number of Rows from the user to draw the Hollow Square For the First and Last Row, Print * for each Column For the Remaining Rows, Print * for the first and Last Column.Example/* Program to print hollow and ... Read More

Advertisements