Tuesday, June 19

Pointers (Lecture Notes) : CUSAT s1s2 Questions




Hi friends,

Here I'm posting some important concepts asked in CUSAT B Tech S1 S2 C programming examination. All the concepts are descried here in very briefly so that you can grasp it quickly.
Here we go..!!! :)



Pointer

· Pointer is a variable that represents the location of a data item.

· Address operator (&) : It evaluates the address of its operand.

· Indirection Operator(*): Used to access data item referenced by a pointer.

Example:

Main()

{

Int a=3;

Int *ptr;

Ptr=&a;

Printf(“%d %u” , *ptr, ptr);

}

Pointer to an array

· A pointer can be used to reference an array.

· The name of an array will work as the pointer to its first element.

Main()

{

Int a[]= { 1, 2 , 3, 4};

Int *ptr =a;

For(int i=0; i<4;i++)

{

Printf(“%d”,* ptr+i);

}

Arrays of Pointers

· A group of pointers are stored in an array.

· Arrays of pointers can be used to store multidimensional arrays

Datatype *array[size];

Structures:

· A collection of heterogeneous elements.

· In structure memory will be allocated for each element.

Struct student {

Char name[20];

Int mark;

};

Union

· Similar to structures, A collection of heterogeneous elements.

· Memory will be allocated for largest member only. Other members have to share this memory.

union student {

Char name[20];

Int mark;

};





Tuesday, June 12

ECIL Graduate Engineer Trainee (GET) recruitment 2012 Computer (CSE) Questions and Answers





Hi Friends,


Here I'm posting the questions asked in ECIL (GET) exam, held on 2012 August 10 , for Computer science, and its detailed solution.
All the questions and answers are collected from memory with the help of  friends..!!!
Hope this will be useful for the preparation for various PSU exams.



Feel free to comment your feedback and doubts ..!!


Here we Go..!! :)


ECIL (GET)
Computer science Stream
Total No Questions: 50
Time Duration: 2 Hrs



(1 )"Bit Stuffing" is used for?
a. Code transparency
b. Synchronization between sender and receiver
c. Data Compression
d. Data Encryption 

Ans: (B) Bit stuffing means inserting a few binary digits to a transmission unit if synchronization pattern is found in data part.The receiver knows how to detect and neglect the stuffed bits.



(2) If inorder traversal of a binary tree is EACKFDBG, what will be its preorder travesal?


(3)Consider the program


main()
{
int x=3, y=7;
modify(x,y,y);
print x;
print y;
}


modify( int x, int y, int z)
{
y= y*2;
z=x+y+z;
}
What will be the output of the program if the arguments are passed to modify through call by reference?

Ans: Since pass by reference is used, After executing,y= y*2; actual values will be x=3, y=14
After this step z=x+y+z; x=3 and y=31
so 3 31 will be printed.




(4) Calculate the Hamming Distance between 010 and 001:
a. 0
b. 1
c. 2
d. 3
Ans:c The Hamming Distance denotes the difference between two binary strings. In the given question difference can be found in 2 positions only. Hence 2 is the hamming distance.



(5)Which of the following is the correct syntax of destructor?
a. x()~
b.x~()
c. x(~)
d.~x()
Ans: (d) ~x() the correct syntax of destructor



(6) How many times the "for" loop in given code fragment will be executed?


main()
{
int i=5;
for( ; scanf("%s", &i) ; printf( "%d", i ));
}


a. for loop never will be executed.
b. for loop will be executed only once.
c. for loop will be executed 5 times
d. for loop will be executed infinite times.

Ans:(d) for loop will be executed infinite times.





(7)Which among the following can input / delete data from both ends , not from the middle?
a. stack
b. linked list
c. queue
d. dequeue

Ans
(d). dequeue





(8)Which among the following involved full code?
a. Black box Test
b. White box Test
c. Integration Test
d. Performance Test

Ans B



(9)What is aliasing?
a. Giving same name to different type of variables.
b. Giving same name for same type of variables.
c. Giving different names for same type of variables
d. Giving different names for same memory location.

(d). Giving different names for same memory location.



(10)float x=4.204 , y=2.103
We can calculate x mod y as:


a. x%y
b. modf(x,y);
c. fmod (x,y);
d. we cannot calculate modulus of two float values in C

Ans C



(11)The type of class accessing primitive data types as objects is called?
a. storage
b. friend
c. virtual
d. wrapper

Ans: D

(12)Which pin is used in 8086 to achieve Mutual exclusion in critical section ?
a. HOLD
b. WAIT
c. RQ/GT
d. LOCK

Ans: d



(13)Which the following operator is used to turn off a particular bit in a byte?
a. ~
b. &&
c. &
d. !

Ans: c

(14) Which among the following correctly explains behavior of a stack?
a. Last element is removed first.
b. Access middle element first
c. Variables can be inserted in any order.
d. variables can be deleted in any order.

Ans: a



(15)Which of the following protocol is used for secure data transfer?
a. HTTP
b. SNMP
c. HTTPS
d. TCP

ans : C



(16) Which of the following is NOT related with inter process communication?
a. pipe
b. semaphore
c. stack
d. mailbox

Ans:C

(17)What is the size of "long double"?
Ans: 10 bytes



(18)What will be the value of FFFF it is a signed integer and is represented by sign magnitude format ?
a. 655536
b. -1
c. -32267
d. 32267

In sign magnitude format the first bit represents sign and it is 1; number is negative. Other bits represent magnitude and its value is 2^15-1. So the answer is -(2^15-1)= -32767



(19) What is the meaning of int (*ptr)[10]
a. pointer to an array of 10 integers.
b. pointer to 10 integer variables
c. array of 10 integer pointers.
d. Array of 10 integers.

Ans :C

(20) In Go - Back N Error control mechanism , after sending N frames, at most how many acknowledgements can be send by the receiver?
a. 0
b. 1
c. N
d. N-1

Ans: C



(21)In a balanced binary tree of N nodes , the difference between left subtree and right subtree will be at most:


a.0
b. 1
c. 2
d. N
Ans: B



(22) Predict the output


main()
{
enum example={ "first", " bin", "akt"};
enum example s1, s2 ,s3;
s1= example.first;
s2= example.akt;
s3= example.bin;
printf("%d %d %d", s1, s2 ,s3);
}


a. 012
b.210
c.021
d.120


Ans: C


(23)Which of the following is NOT true about RS 485?


(24)Which of the following represented by the term Base FX?
a. Thin wire Ethernet
b. Thick wire Ethernet
c. Twisted pair Ethernet
d. Optical Fiber
Ans: D

(25)Which of the following is NOT related with Transport Layer?
a. error control
b. flow control
c. routing


(26)If in a given cache system, 99.99% is the hit ratio ,and the processing time for hit and miss events are 1 microseconds amd 1 milliseconds respectively, the calculate the average processing time?




(27)If 192.97.28.91 and 192.97.28.131 are connected in same network, then which of the following cannot be used for subnet masking?


a. 255.255.255.0
b. 255.255.255.192
c. 255.255.255.126
d. 255.255.255. 224


(28) Which of the following is the property of bipartite graphs of N nodes?
a. There will be N edges
b. There will be only one odd cycle.
c. There will be No odd cycle
d. There will be N^2 Edges.


(29)Which among the following is the statement for dynamic allocation of characters?
Ans: char *p= (char *) malloc[20];


(30) Float to integer conversion is perfectly done in which statement?
float x;
Ans : int i=(int)(x+0.5)






(31)Which is true about "isotopes"?
a. Number of protons is equal
b. Number of neutrons is equal
c. Number of protons is different
d. Number of both protons and neutrons are equal.




(32)Which operator is used to declare member functions outside the class body?
Ans ::


(33)The member elements can be accessed by the pointer variable of a structure using the operator?
Ans: ->


(34)In UML notation which diagram is used to depict the interaction between software and hardware?
Ans: Deployment Diagram




(35)In 8085, ALE signal is used. but it is not is 6086. Why?
a. In 8085 multiplexing is used for communication but not in 6086
b. In 8085 only IO mapped IO is used whereas in 6086 only memory mapped IO is used.


Ans a


(36)If the given sampling frequency is 10 MHz , then for successful transmission bandwidth should be?
a. 5 MHz
b. 10 MHz
c. 20 MHz
d. 100 M Hz

Ans (a)The Nyquist–Shannon sampling theorem states that perfect reconstruction of a signal is possible when the sampling frequency is greater than twice the maximum frequency of the signal being sampled.

Bandwidth = sampling frequency /2= 10/2= 5 MHz



(37)What is the use of "segmentation" in a computer system?


(38) In CSMA/ CD, vulnerable time may be:
a. Round trip time.
b. Time to transmit one complete frame
c. Time to transmit two complete frames
d.Time to reach at the destination.




(39)Which among the following is Non - Linear?
a. Low pass filter
b. Rectifier.
c. High pass filter
d. All the above

Ans: d) A non linear circuit does not have a linear relationship between current and voltage



(40)What is the purpose of Rectifier?
a. To convert DC to AC
b. To convert AC to DC
c. To eliminate Noise.
d. To eliminate DC component.


Ans :B

(41)Associative memory mapping is free from
a. conflict collision
b. capacity collision

Ans :a

 

(42) Address length of IPV4 and IPV6?
Ans: 4 bytes, 16 bytes




(43) In selection sort, after 42 successful iteration of main loop , at least how many elements will be sorted?


a. 41
b. 42
c. 21
d. 43

Ans : b

(44)which one of the following is a hashing algorithm?
a)SHA
b)AES
c)
DES


Ans :A

(45). Aggregate function to count number of rows?

(46). Diagrams to represent Relational database?


(47) what is crc in error control mechanism? 


a) dividend 
b) remainder
c) divisor 
d) quotient 

Ans : b



All the questions were collected from memory.


If you know any other questions, feel free to comment it here..!!!! :)

Thursday, May 31

SELECTION SORT ~ CUSAT Previous Questions with Answers- C programming.( S1 S2)



Hi friends,

Here I'm posting a C program implementing Selection sort. It is specially dedicated to S1 S2 B tech students because Selection sort is one of the most frequently asking questions in "Computer  Programming" exams. Hope this will be Useful  4  you.!!! :)



#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n,i,j,temp,a[50]; 


printf("\nEnter how many elements=");
scanf("%d",&n); 


printf("\nEnter %d elements",n);//
Input the elements
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);




for(i=0;i<n-1;i++)//
Sorting the elements
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
}
printf("\nSorted Array:\n");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}

}


Any doubt in the code? Comment it here..!!

Monday, May 28

CUSAT Previous Questions with Answers- C programming.( S1 S2)





Hi Friends,


here I'm posting one of the frequently asking question in CUSAT B tech C programming ( s 1 s2 ) and its solution:

Question:



Write a C program which prints all Armstrong numbers between 1 and 1000.


Solution:



#include<stdio.h>
main()
{
int number, temp, digit=0, dup;

printf("Printing all Armstrong numbers between 1 and 500:\n\n");

number = 1;

while (number <= 500)
{
temp=0;
dup=number;
while(dup>0)
{
digit=dup%10;
temp+=(digit*digit*digit);
dup=dup/10;
}
if (temp==number)
{
printf("\nAmstrong Number:%d", temp);
}
number++;
}
getch();
}
 

Thursday, May 24

CIL Coal India MT Computer Science Previous Year Question with Answer



Hello reader,


In this post we shall go through some questions asked in CIL( Coal India Ltd)  MT Exam, with complete solution. Hope it will be useful to You. If you have  any feedback or doubts about any solution please  comment it here.!!! It will be helpful for others also.!!!


The order of an internal node in a B+ tree index is the maximum number of children it can have. Suppose that a child pointer takes 6 bytes, the search field value  takes 14 bytes, and the block size is 512 bytes. What is the order of the internal node?
A) 24 B) 25 C) 26 D) 27
 

Answer : (C)

The Boolean function x' y' + xy + x' y
A) x'+ y' B) x + y C) x + y' D) x' + y
Answer : (D)

In an MxN matrix such that all non-zero entries are covered in a rows and b columns. Then the maximum number of non-zero entries, such that no two are on the same row or column, is

A) £ a + b B) £ max {a, b} C) £ min {M-a, N-b} D) £ min {a, b}
Answer : (A)

The minimum number of page frames that must be allocated to a running process in a virtual memory environment is determined by
A) the instruction set architecture B) page size C) physical memory size D) number of processes in memory
Answer : (D)

The best data structure to check whether an arithmetic expression has balanced parentheses is a
A) queue B) stack C) tree D) list
Answer : (B)

 The address resolution protocol (ARP) is used for
A) Finding the IP address from the DNS
B) Finding the IP address of the default gateway
C) Finding the IP address that corresponds to a MAC address
D) Finding the MAC address that corresponds to an IP address
Answer : (D)

The goal of structured programming is to
A) have well indented programs
B) be able to infer the flow of control from the compiled code
C) be able to infer the flow of control from the program text
D) avoid the use of GOTO statements
Answer : (C)


Which data structure has the fastest insertion procedure?
A) Binary search tree
B) Ordered array
C) Heap
D) Unordered linked list
E) Ordered linked list

Answer: (D)

SQL is the combination of
A ) DDL and DQL
B ) DDL , DML and DQL
C ) DDL,DML,DQL and DCL
D ) None of these

Answer: (C)

Which of the following applications may use a stack?
A) A parentheses balancing program.
B) Keeping track of local variables at run time.
C) Syntax analyzer for a compiler.
D) All of the above

Answer: (D)

Which of the following is not a type of Operating System ?
(A) Multi-programming
(B) Time-sharing
(C) Real-time  
(D) Concurrent Programming

Answer : (D)

The mechanical, magnetic, electronic and electrical devices from which a computer is fabricated is called :
(A) Magnetic Core
(B) Firmware
(C) Hardware
(D) Software

Answer :  C

 The most efficient data-type for a variable that stores the number 4.6 e 20 is the _______ data-type.
(A) Character
( B) Float
(C) Long integer
(D) Short integer

Answer : B
 

Which of the following is a logical OR operator ?
(A) &&  
(B) ||
(C) ? :
(D) &

Answer : B


 Which of the following is not a valid declarations for a C++ character string ?

(A) char S[6] ;
(B) char S[6] = “Hello” ; 
(C) char * S ;
(D) char S[ ] ;

Answer : D

  A function’s single most important role is to :
(A) give a name to a block of code (B) reduce program size
(C) accept arguments and provide a return value  (D) help in organizing a program into conceptual units

Answer : D

 Which of the following 4-bit number equals its 2’s Complement ?
(A) 1010  
(B) 1000
(C) 0101
(D) 1100

Answer :  B

 The basic unit of measurement used for measuring opposition to current flow in a circuit is :
(A) volt
(B) ampere
(C) ohm
(D) watt

Answer :  C

 Programming in a language that actually controls the path of signals or data within a computer is called :
(A) Micro-programming 
(B) System programming
(C) Assembly programming
(D) Machine programming

Answer : A

 Which of the following is not a port/connection ?
(A) PS-2
(B) COM
(C) SMPS
(D) LPT

Answer : C



What is the output of the following code ?
for (int a = 1; a < = 1; a++) cout << a++; cout << a;

(A) 22 (B) 12 (C) 13 (D) 23

Answer : C

 Inheritance is a way to :
(A) organize data
(B) pass arguments to objects of classes
  (C) add features to existing classes without rewriting them
(D) improve data-hiding and encapsulation

Answer :  C

 What is a Constructor ?

  (A) A function called when an instance of a class is initialized
(B) Function that is called when an instance of a class is deleted
(C) A special function to change the value of dynamically allocated memory
(D) A function that is called in order to change the value of a variable

Answer :  A


Which of the following gives the value stored in pointer a ?
(A) a; (B) val(a);
  (C) *a;(D)  &a;
Answer :  C


Array passed as an argument to a function is interpreted as :
(A) Address of the array
(B) Value of the first element of the array
(C) Address of the first element of the array
(D) Number of elements of the array

Answer :  C

 Which of the following is the feature of stack ?
 (A) All operations are at one end 
(B) It cannot reuse its memory
(C) All elements are of different data types
(D) Any element can be accessed from it directly

Answer :  A

 What is the Postfix Expression for the following Infix (Inorder) expression ?

2*3-4/5
  (A) 23*45/-(B) 23*-45/
(C) 23*45-/ (D) *23/45-

Answer : A

 Binary search requires data to be in what order ?
(A) Increasing (B) Decreasing
(C) Random   (D) Sorted

Answer :  D


 You are making your own database so that you can organize information about your ‘Top 100’ movies. You want to include information like Title, Actor (s),Director, Year etc. Each record in your database will represent :

  (A) An actor (B) A director
(C) A year   (D) A movie

Answer :  D


 What will be a suitable criterion that should be entered for a query to search for Employee Names beginning with M ?
  (A) Start with M (B) Like M
(C) Like M*   (D) Like ‘M*’
  Answer :  D


A field that is a primary key in another table is called a _______ .
(A) special key   (B) foreign key

(C) simple key (D) composite key
Answer :  B


  This aggregate SQL function will return the number of rows in a database table :
  (A) COUNT (*)(B) Rows (*)
(C) NUM (*) (D) SUM (*)

Answer :  A

 Which topology requires a central controller or hub ?
(A) Mesh   (B) Star
(C) Bus (D) Ring

 Answer :  B


 In_______transmission, the channel capacity is shared by both communicating devices at all times :
(A) Simplex (B) Half-duplex
(  C) Full-duplex  (D) Half-simplex

Answer :  C

  ________is the protocol suite for the current Internet.
  (A) TCP/IP(B) NCP
(C) UNIX (D) ACM

Answer : A
  In C++, to write data containing variables of type float, to an object of type of stream, you should use :

(A) The insertion operator (B) seek ()
  (C) write ()(D) put ()

Answer : C

A message from device A consists of packet X and packet Y. In the virtual circuit approach to packet switching, packet Y’s path ____________ packet X’s.
  (A) is the same as(B) is dependent on
(C) is independent of (D) is always different from
  Answer :  A

There are n devices arranged in a ring topology. A device is deleted. There are now _____ links of cable.

  (A) n – 1  (B) n – 2
(C) n (D) n + 1
 Answer :  A

 Which factor makes twisted-pair cable superior to fiber-optic cable ?
(A) signal attenuation (B) noise resistance
(C) bandwidth range (  D) cost


Answer :  D



hAve  feedback? or doubts? please  comment it here.!!! It will be helpful for others also.!!!
- Thank You.!!!!



KERALA ENTRANCE ( ENGINEERING AND MEDICAL - KEAM) RESULTS ~ KNOW YOUR RANK



Hi reader,

 The result of Kerala Engineering & Medical Entrance  exam, one of the most prestigious competitive exams in Kerala, is supposed to be arrived, today (24-05-2012). The following links will help you to know  your result.

All the best wishes.!!!



Check it now.!!!!

http://www.cee-kerala.org/

http://www.cee.kerala.gov.in/keamresults2012/main/login.php








Monday, May 21

Generate Interesting Patterns Using C

Hi friends,

Look at the "+"  pattern generated by asterisks. Quite interesting na..!! :)
Lets have a look in a C program which generates exactly the same pattern.!!!!!

 main()
{
int i,j;
for ( i= 0; i < 11; ++i)
{
for ( j = 0; j < 11; ++j)
      if (j != 5 && i !=5 )
     printf(" "); 
      else printf ("* ");
printf("\n");
}
}