Mandalika has Published 475 Articles

Write an example program on structure using C language

Mandalika

Mandalika

Updated on 05-Mar-2021 08:27:11

409 Views

The structure is a collection of different datatype variables, grouped together under a single name Syntax.Declaration and initialization of structuresThe general form of structure declaration is as follows −datatype member1; struct tagname{    datatype member2;    datatype member n; };Here, struct - keyword         tagname - specifies name ... Read More

What is the use of sprintf() and sscanf() functions in C language?

Mandalika

Mandalika

Updated on 05-Mar-2021 08:22:29

4K+ Views

The sscanf() functionIt reads data from a character string.Syntaxsscanf(string, formatspecifier, &var1, &var2, ……..)String refers to the char string to read from.Format string refers to char string containing certain required formatting information.Var1, var2 etc., represent the individual input data items.For example, sscanf(string, "%d%d", &hours, &minutes);The sprintf() functionThis function is used to ... Read More

Explain else-if ladder statement in C language

Mandalika

Mandalika

Updated on 22-Feb-2021 06:44:48

10K+ Views

This is the most general way of writing a multi-way decision.SyntaxRefer the syntax given below −if (condition1) stmt1; else if (condition2) stmt2; - - - - - - - - - - else if (condition n) stmtn; else stmt x;AlgorithmRefer the algorithm given below −START Step 1: Declare int variables. ... Read More

Explain if-else statement in C language

Mandalika

Mandalika

Updated on 22-Feb-2021 06:43:43

1K+ Views

If-else statement takes care of true as well as false conditions. ‘true block’ is executed, when the condition is true and ‘false block’ (or) ‘else block’ is executed, when the condition is false.SyntaxRefer the syntax given below −if (condition){    True block statement(s) }else{    False block statement(s) }Working of ... Read More

What is a malloc function in C language?

Mandalika

Mandalika

Updated on 20-Feb-2021 10:27:42

6K+ Views

The malloc() function stands for memory allocation, that allocate a block of memory dynamically.It reserves the memory space for a specified size and returns the null pointer, which points to the memory location.malloc() function carries garbage value. The pointer returned is of type void.The syntax for malloc() function is as ... Read More

What is Evaluation, Precedence and Association in C language?

Mandalika

Mandalika

Updated on 20-Feb-2021 05:17:24

3K+ Views

Expressions are evaluated by the ‘C’ compiler based on precedence and associativity rules.If an expression contains different priority operators, then the precedence rules are considered.Here, 10*2 is evaluated first since ‘*’ has more priority than ‘- ‘and ‘=’If an expression contains same priority, then associativity rules are considered i.e. left ... Read More

What is COBOL host variable equivalent for various DB2 data types?

Mandalika

Mandalika

Updated on 01-Dec-2020 05:07:03

576 Views

Problem: How will the COBOL-DB2 program behave when there is a mismatch between the host variable and number of columns in the SELECT statement?SolutionIn case there is a mismatch in the number of columns and number of host variables, the query will fail. For example, if we have used the ... Read More

What is the purpose and usage of “FOR UPDATE OF” clause in a COBOL-DB2 program

Mandalika

Mandalika

Updated on 01-Dec-2020 05:05:31

3K+ Views

Problem: What is the purpose of the "FOR UPDATE OF" clause in a cursor? What will happen if we fire an UPDATE statement without using this clause in a COBOL-DB2 program?SolutionThe “FOR UPDATE OF” clause is given in the cursor declaration and it is used when we want to update ... Read More

What is update operation on the cursor having JOIN between 2 tables?

Mandalika

Mandalika

Updated on 01-Dec-2020 05:04:28

581 Views

Problem: Is it possible to update a CURSOR in which we have used JOIN on 2 tables ORDERS and TRANSACTIONS? Why or why not? How can we proceed to UPDATE any of these tables?SolutionWhenever we use JOIN in a cursor on two or more tables (ORDERS and TRANSACTIONS in this ... Read More

What is the execution result when non-SQL changes are made in the program without BIND?

Mandalika

Mandalika

Updated on 01-Dec-2020 05:03:14

151 Views

Problem: A COBOL-DB2 program is changed to increase the length of a variable from PIC X(5) to PIC X(8). However, there are no changes in the SQL of the program. What will be the result if the program's plan/package is not binded for these changes?SolutionThe variable length change from PIC ... Read More

Advertisements