Anda di halaman 1dari 4

Q81.

1.char *p[3];

2.char (*p)[3];

3.float* (*func)(int *);

4. void (*fun)();

Q82.
#include<stdio.h>
#include<stdlib.h>
/* Link list node */
struct node
{
int data;
struct node* next;
};
void push(struct node** head_ref, int new_data)
{
/* allocate node */
struct node* new_node =
(struct node*) malloc(sizeof(struct node));
/* put in the data */
new_node->data = new_data;
/* link the old list off the new node */
new_node->next = (*head_ref);
/* move the head to point to the new node */
(*head_ref) = new_node;
}
int detectloop(struct node *list)
{
struct node *slow_p = list, *fast_p = list;
while(slow_p && fast_p &&
slow_p->next &&
fast_p->next &&
fast_p->next->next )
{
slow_p = slow_p->next;
fast_p = fast_p->next->next;
if (slow_p == fast_p)
{
printf("Found Loop");
return 1;
}
}
return 0;
}
/* Drier program to test above function*/
int main()
{
/* Start with the empty list */
struct node* head = NULL;
push(&head, 20);
push(&head, 4);
push(&head, 15);
/* Create a loop for testing */
head->next->next = head;
detectloop(head);
getchar();
}
Q91.
Pointers to far objects are stored using four bytes (32 bits). The bytes are sto
red little endian or low to high order. The first word contains the 14-bit memor
y offset (bits 14 and 15 are always 0). The second word contains the page number
(or segment number for function pointers). The memory address is calculated as
follows:
Variable Address = (Page * 0x4000L) + Offset
Function Address = (Segment * 0x10000L) + Offset

Q92.

void
printClass::printString(CDC *dc, char *str, int x, int y)
{
CPrintInfo Info;
int w = dc->GetDeviceCaps(HORZRES);
int h = dc->GetDeviceCaps(VERTRES);
Info.m_rectDraw.SetRect(x,y, w, h);
CRect r = Info.m_rectDraw;
// Calculate the size of the rect but do not print
(void)dc->DrawText(str, strlen(str), r,
DT_CALCRECT|DT_WORDBREAK|DT_NOCLIP|DT_EXPANDTABS);
//print string
dc->DrawText(str, strlen(str), r,
DT_WORDBREAK|DT_NOCLIP|DT_EXPANDTABS);
}
void
printClass::printTestString()
{
CPrintDialog printDlg(FALSE);
CDC dc;
char *strTitle = "Title";
// ask the user to select a printer
if (printDlg.DoModal() == IDCANCEL) return;
dc.Attach(printDlg.GetPrinterDC());
dc.m_bPrinting = TRUE;
dc.SetMapMode(MM_TEXT);
DOCINFO di;
memset(&di, 0, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
// application title appears in the spooler view
di.lpszDocName = strTitle;
// Begin a new print job
BOOL bPrintingOK = dc.StartDoc( &di );
dc.StartPage();
printString(&dc, "This is a test string", 0,0);
// end page
bPrintingOK = (dc.EndPage() > 0);
if (bPrintingOK) dc.EndDoc();
else dc.AbortDoc();
// detach the printer DC
dc.Detach();
}

Q93.

The variables of register type modifier will inform the compiler for storing the v
ariables in a register of CPU.
The advantage of this type modifier is the access optimization and speed of prog
ram execution. The operations of these variables are faster by orders of magnitu
de.

Q.94.

free() is a function used to free the memory allocated dynamically by both mallo
c and calloc functions.
free(ptr): ptr is a pointer to a memory block which has already been creeated by
malloc or calloc.

Q95.
stdarg.h
Q98.
#include<stdio.h>
#include<conio.h>
int main(void)
{
int sum=0,n=0;
printf("\n how many numbers do u want to add);
scanf("%d",&n);
for(int j=0;j<n;j++)
{
printf("\n Enter a number");
scanf("%d",&i);
sum=sum+i;
}
printf("\nSum=%d",sum);
return 0;
}

Q99.
include <stdio.h>
#include <conio.h>
void main()
{
int year,leap;
clrscr();
printf("enter the year:- ");
scanf("%d",&year);
if ((year%100)==0)
leap=(year/400)*400;
else
leap=(year/4)*4;
if (leap==year)
printf("
%d is a leap year.",year);
else
printf("
%d is not a leap year.",year);
getch();
}

Anda mungkin juga menyukai