Saturday, 18 July 2020

Macro C Language

 What is macro? Define a macro to compute maximum of two arguments passed to it.



macro is a fragment of code which has been given a name. Whenever the name is used, it is replaced by the contents of the macro. There are two kinds of macros. They differ mostly in what they look like when they are used. Object-like macros resemble data objects when used, function-like macros resemble function calls.
#include <stdio.h>

#define MAX(x,y) ((x>y)?x:y)
/*=======================
     Girfa Student Help
     Macro Demo
 ========================*/

fseek demo program

Q : Write a file statement to place a file pointer (fp) at the beginning of the record number (say R), where record size is B bytes.


Answer : 

#include<stdio.h>

#include<conio.h>

/*============================

     Girfa Student Help

     fseek demo

==============================*/

Friday, 17 July 2020

Structure for Employee

A programmer wants to use two variables session and info. Variable session can take three values (morning, afternoon, evening) ly. Using variable info, the programmer wants to access information empname and empid of 30 employees. Name the appropriate data type used for each variable session and info and declare the variables.

Answer : 



#include<stdio.h>
#include<conio.h>
/*============================
     Girfa Student Help
     structure data type
==============================*/

Difference and similarity between continue and break | C Language

Write down one similarity and one dissimilarity between break and continue statements.


Similarity


The main difference between break and continue statements in C language is that a break origins the innermost enclosing loop or switch to be exited immediately. Whereas, the continue statement origins the next iteration of the enclosing for, while, or do loop to begin. The continue statement in while and do loops takes the control to the loop's test-condition immediately, whereas in the for loop it takes the control to the increment step of the loop.