Tag Archives: 2007

Write a macro to find the smallest number among 3 given numbers. 7m Jun2007

Write a macro to find the smallest number among 3 given numbers. 7m Jun2007 Code: #include<stdio.h> #define MIN(X,Y)(X<Y ? X:Y) #define SMALL(X,Y,Z)(MIN(X,Y)<Z ? MIN(X,Y):Z) void main() { int FIRST,SECOND,THIRD; clrscr(); printf(“ENTER NUMBERS TO COMPARE\n”); printf(“\nFIRST NUMBER : “); scanf(“%d”, &FIRST); printf(“\nSECOND NUMBER : “); scanf(“%d”, &SECOND); printf(“\nTHIRD NUMBER : “); scanf(“%d”, &THIRD); printf(“\nThe SMALLER NUMBER IS… Read More »

A computer has 32 words RAM with a word size of 16 bits and a cache memory of 4 Blocks with block size of 16 bits. 10m Dec2007

Assume a computer has 32 words RAM each having a word of 16 bits and a cache memory of 4 blocks, with each block having 16 bits. Where can we find a main memory address 21 in the cache (if it exists) if (i) Set associative mapping is used? (ii) Direct mapping is used? (iii)… Read More »

Find the average access time for the disk. 4m Dec2007

Seek time on a hard disk is 50 ms. it rotates at a speed of 3000 rotations/sec. Each track on the disk has 100 sectors. Find the average access time for the disk. 4m Dec2007 Disk Rotation Speed = 3000 rps.  (i.e. 180000 rpm) Sectors per Track = 100 sectors Seek time = 50 millisecond  … Read More »

Simplify Boolean function using Karnaugh map method F (A, B, C, D): Σ (0, 2, 4, 5, 6, 7, 8, 10, 13, 15) Also, draw the corresponding logic circuit diagram. 8m Jun2007

Construct the Karnaugh map for the following function, and find the function in sum of product form. Draw the resultant logic diagram. F (A, B, C, D): Σ (0, 2, 4, 5, 6, 7, 8, 10, 13, 15). 5m Dec2007  K-Map for F is: Thus, the simplified equations for F (A, B, C, D) =… Read More »

Write a program in ‘C’ language that accepts the name of a file as input and prints those lines of the file which have the word ‘this’. 10m Dec2007

Write a program in ‘C’ language that accepts the name of a file as input and prints those lines of the file which have the word ‘this’. 10m Dec2007    #include<stdio.h> void main() { FILE *fp; int cnt=0; char str[80],lines[400]; clrscr(); if ((fp=fopen(“test.txt”,”r”))== NULL) { printf(“File does not exist\n”); exit(0); } while(!(feof(fp))) { fgets(str,80,fp); if(strcmp(“this”,str))… Read More »

A program in ‘C’ language to display the names and seat numbers of all passengers of a bus in the form of a singly linked list. Use pointers. 10m Dec2007

Write a program in ‘C’ language to display the names and seat numbers of all passengers of a bus in the form of a singly linked list. Use pointers. 10m Dec2007   #include<stdio.h> struct node { int seat; char name[20]; struct node *next; }; typedef struct node node; //with this Use “node” instead of “struct… Read More »

A program in ‘C’ language which accepts enrollment number as input and prints the name of student. pairs of students in the form of a matrix. 10m Dec2007

Write a program in ‘C’ language which accepts the enrollment number of a student as input and prints the name of that student. The program should initially store information about the (name, enrollment number) pairs of students in the form of a matrix. 10m Dec2007   #include<stdio.h> struct student { unsigned long int ENROL; char… Read More »

Write an algorithm and draw flowchart to find whether a given string S1 is substring of another string S2. 10m Dec2007

Write an algorithm and draw flowchart to find whether a given string S1 is substring of another string S2. 10m Dec2007   Algorithm Step 1: Input String and Substring (Note: Substring should be smaller than String) Step 2: Find Length of String (Len1) and Find Length of Substring (Len2) Step 3: flag <- 0 Step… Read More »

List and explain the precedence of Arithmetic, Logical and Relational operators in ‘C’. 10m Dec2007

List and explain the precedence of Arithmetic, Logical and Relational operators in ‘C’. 10m Dec2007 C uses a certain hierarchy to solve such kind of mixed expressions. The hierarchy and associatively of the operators discussed so far is summarized in Table. The operators written in the same line have the same priority. The higher precedence operators are written… Read More »

Write the syntax for the declaration of a function. Also discuss the parameter passing methods with an example program. 10m Dec2007

Explanation of FUNCTION: A function is a block of code that has a name and it has a property that it is reusable i.e. it can be executed from as many different points in a C Program as required. Function groups a number of program statements into a unit and gives it a name. This… Read More »