Found 1439 Questions for C

C program to find maximum of four integers by defining function

Arnab Chakraborty
Updated on 08-Oct-2021 10:53:33
Suppose we have four numbers a, b, c and d. We shall have to find maximum among them by making our own function. So we shall create one max() function that takes two numbers as input and finds the maximum, then using them we shall find maximum of all four numbers.So, if the input is like a = 5, b = 8, c = 2, d = 3, then the output will be 8To solve this, we will follow these steps −define a function max(), this will take x and yreturn maximum of x and ytake four numbers a, b, ... Read More

C program to find sum and difference of two numbers

Arnab Chakraborty
Updated on 08-Oct-2021 10:50:57
Suppose we have two integer numbers a, b and two floating point numbers c, d. We shall have to find the sum of a and b as well as c and d. We also have to find the sum of a and c as well. So depending on the printf function style, output may differ.So, if the input is like a = 5, b = 58 c = 6.32, d = 8.64, then the output will be a + b = 63 c + d = 14.960001 a + c = 11.320000To solve this, we will follow these steps −To ... Read More

C Program to read and write character string and sentence

Arnab Chakraborty
Updated on 08-Oct-2021 10:48:36
Suppose you want to take a character, then a string and a sentence (string with spaces) using C. So we shall provide three inputs and print the same as output. The maximum size of the string is 500 here.So, if the input is likecharacter = 'T' string = "ProgrammingLanguage" sentence = "I love programming through C", then the output will beYour character: T Your string: ProgrammingLanguage Your sentence: I love programming through CTo solve this, we will follow these steps −For character we need to use scanf("%c", &character);For string we need to use scanf("%s", string);This step is optional, but required ... Read More

What are the special symbols in C language?

Bhanu Priya
Updated on 03-Sep-2021 07:27:07
In C programming language, generally, the special symbols have some special meaning and they cannot be used for other purposes.Some of the special symbols that are used in C programming are as follows −[] () {}, ; * = #Let’s understand their definitions, which are as follows −Brackets[] − Opening and closing of brackets are used for array element reference, which indicate single and multidimensional subscripts.Parentheses() − These special symbols are used for function calls and function parameters.Braces{} − Opening and closing of curly braces indicates the start and end of a block of code which contains more than one ... Read More

What are the constants with an example in C language?

Bhanu Priya
Updated on 03-Sep-2021 07:23:16
Constant is also known as variable where once defined, the value never changes during the program execution. Thus, we can declare a variable as constant that refers to fixed values. It is also called as literals. Const keyword has to be used to define a constant.SyntaxThe syntax for constant that is used in C programming language is given below −const type VariableName; (or) const type *VariableName;Different types of constantsThe different types of constants that are used in C programming language are as follows −Integer constants − For example: 1, 0, 34, 4567Floating-point constants − For example: 0.0, 156.89, 23.456Octal & ... Read More

What is an identifier and its rules in C language?

Bhanu Priya
Updated on 03-Sep-2021 07:20:46
Identifier is one of the tokens which are used in C programming language. It is a name which is used to identify the variables, constants, functions, arrays, and also user-defined data.We cannot use keywords as identifiers because keywords are reserved for special use. Once declared, we can use the identifier in later program statements which refers to the associated value.The special kind of identifier is known as a statement label and it can be used in goto statements.RulesThe rules for naming identifiers are as follows −Identifier names are unique.Cannot use a keyword as identifiers.Identifier has to begin with a letter ... Read More

What are the different types of keywords in C language?

Bhanu Priya
Updated on 03-Sep-2021 07:18:01
Keywords are generally called as pre-defined or reserved words in a programming language. Every keyword in C language performs a specific function in a program.Keywords cannot be used as variable names.Keywords have fixed meanings, and that meaning cannot be changed.They are the building block of a 'C' program.C supports 32 keywords.All the keywords are written in lowercase letters.The different types of keywords are as follows −autodoubleintstructbreakelselongswitchcaseenumregistertypedefcharexternreturnunionconstshortfloatunsignedcontinueforsignedvoiddefaultgotosizeofvolatiledoifstaticwhileExampleGiven below is the C program for the Simple Calculator by using the Switch Case − Live Demo#include int main(){    char Operator;    float num1, num2, result = 0;    printf(" Try to Enter ... Read More

What are the tokens in C ?

Bhanu Priya
Updated on 03-Sep-2021 07:14:32
A token is nothing but a smallest element of a program which is meaningful to the compiler. The compiler that breaks a program into the smallest units is called tokens and these tokens proceed to the different stages of the compilation.TypesTokens are classified into different types, which are mentioned below −KeywordsIdentifiersConstantsStringsSpecial SymbolsOperatorsExampleGiven below is the C program the use of identifiers, keywords, variables etc. Live Demo#include int main(){    int a, b, c;    printf("enter a and b values: ");    scanf("%d%d", &a, &b);    c=a*b;    printf("value of c=%d", c);    return 0; }OutputWhen the above program is executed, ... Read More

How to convert binary to Hex by using C language?

Bhanu Priya
Updated on 03-Sep-2021 07:09:29
Binary numbers are represented in 1’s and 0’s.Hexadecimal number system with 16 digits is {0, 1, 2, 3…..9, A(10), B(11), ……F(15)}To convert from binary to hex representation, the bit string id is grouped in blocks of 4-bits which are called as nibbles from the least significant side. Each block is replaced by the corresponding hex digit.Let’s see an example to get the clarity on hexadecimal and binary number representation.0011 1110 0101 1011 0001 1101   3    E    5    B   1    DWe write 0X3E5B1D for a hex constant in C language.Another example which What iss how ... Read More

What are different types of data in C language?

Bhanu Priya
Updated on 03-Sep-2021 07:05:41
Datatype is the declaration of memory location or variable. Data can be of different types and some of the examples of data types in C language are as follows −Integers, rational numbers, whole numbers, real numbers, complex numbers, vectors, characters etc.Coming to the machine hardware, the data is everything encoded as a string of binary digits 0 and 1 of finite length. In the machines, the integer data is processed in the arithmetic logic unit (ALU) and fractional data is processed in the floating-point unit (FPU). This gets reflected in the built-in or primitive data types of a high-level language.Built-in ... Read More
Advertisements