Bhanu Priya has Published 1581 Articles

C program to convert centimeter to meter and kilometer

Bhanu Priya

Bhanu Priya

Updated on 24-Mar-2021 13:03:38

4K+ Views

Here, the user has to enter the length in centimeters (cm), and then, convert the length into meters (m), and kilometer (km).1 Meter = 100 Centimeters 1 Kilometer = 100000 CentimetersAlgorithmRefer an algorithm given below to convert centimeter into meter and kilometer respectively.Step 1: Declare variables. Step 2: Enter length ... Read More

C program to find the sum of arithmetic progression series

Bhanu Priya

Bhanu Priya

Updated on 24-Mar-2021 12:55:26

1K+ Views

ProblemFind the sum of an arithmetic progression series, where the user has to enter first number, total number of elements and the common difference.SolutionArithmetic Progression (A.P.) is a series of numbers in which the difference of any two consecutive numbers is always the same. Here, total number of elements is ... Read More

C program to generate an electricity bill

Bhanu Priya

Bhanu Priya

Updated on 24-Mar-2021 12:54:05

6K+ Views

Based on the units consumed by the user, the electricity bill is generated. If number of units consumed are more then, the rate of a unit charge will also increase.The logic applied if minimum units are consumed by the user is as follows −if (units < 50){    amt = ... Read More

How to add two complex numbers by passing structure to a function in C language?

Bhanu Priya

Bhanu Priya

Updated on 24-Mar-2021 12:36:51

6K+ Views

In order to add two complex numbers in C programming language, the user has to take two complex numbers as structure members and perform addition operation on those two numbers by creating a user-defined function.AlgorithmRefer an algorithm given below for addition of two complex numbers.Step 1: Declare struct complex with ... Read More

Explain the concept of an array within a structure in C programming

Bhanu Priya

Bhanu Priya

Updated on 19-Mar-2021 10:47:59

4K+ Views

An array of structure in C programming is a collection of different datatype variables, grouped together under a single name.General form of structure declarationThe structural declaration is as follows −struct tagname{    datatype member1;    datatype member2;    datatype member n; };Here, struct is the keyword.tagname specifies the name of ... Read More

C program demonstrating the concepts of strings using Pointers

Bhanu Priya

Bhanu Priya

Updated on 19-Mar-2021 10:16:59

1K+ Views

An array of characters is called a string.DeclarationThe syntax for declaring an array is as follows −char stringname [size];For example − char string[50]; string of length 50 charactersInitializationUsing single character constant −char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char string[10] = "Hello":;Accessing − There is ... Read More

C program to print array of pointers to strings and their address

Bhanu Priya

Bhanu Priya

Updated on 19-Mar-2021 10:04:52

7K+ Views

First, let us understand what are the arrays of pointers in C programming language.Arrays of pointers: (to strings)It is an array whose elements are ptrs to the base add of the string.It is declared and initialized as follows −char *a[ ] = {"one", "two", "three"};Here, a[0] is a pointer to ... Read More

What is strstr() Function in C language?

Bhanu Priya

Bhanu Priya

Updated on 19-Mar-2021 10:03:30

779 Views

The C library function char *strstr(const char *haystack, const char *needle) function finds the first occurrence of the substring needle in the string haystack. The terminating '\0' characters are not compared.An array of characters is called a string.DeclarationThe syntax for declaring an array is as follows −char stringname [size];For example ... Read More

What is strrev() Function in C language?

Bhanu Priya

Bhanu Priya

Updated on 19-Mar-2021 10:01:46

3K+ Views

An array of characters is called a string.DeclarationThe syntax for declaring an array is as follows −char stringname [size];For example − char string[50]; string of length 50 charactersInitializationUsing single character constant −char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char string[10] = "Hello":;Accessing − There is ... Read More

What is strncmp() Function in C language?

Bhanu Priya

Bhanu Priya

Updated on 19-Mar-2021 10:00:39

3K+ Views

The C library function int strncmp(const char *str1, const char *str2, size_t n) compares at most the first n bytes of str1 and str2.An array of characters is called a string.DeclarationThe syntax for declaring an array is as follows −char stringname [size];For example − char string[50]; string of length 50 ... Read More

Advertisements