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");
}
}