12.24.2011

Middle level Language

Q. Why C is called middle level language?

Ans.

It is common question in interview that why C language is called a Middle level language? Before find out this answer, you should familiar with following term:
There are following reason that C is called Middle Level Language as:

Low Level Language

LLL is stand for Low Level Language. These language also known Machine Language. Definition and some Basic features of low level Language is as following:
  • The language whose design is governed by the circuitry and the structure of the machine is known as Machine Language.
  •  These language is difficult to learn and use.
  • These language is machine-dependent.
  • In these type language program execution is faster compere high level language because code is directed accepted by the machine, no needs to translator.
  • Example of Low level Language is the Assembly Language.

High Level Language


HLL stands for High Level Language. Basic features of HLL is as  following:
  • These language are particularly oriented towards describing the procedures for solving the problem in a concise, precise and unambiguous manner. 
  • HLL are programming language which is user friendly, easy to learn and writing program, to extent platform independent.
  • Hll language are machine independence so its require Compiler or Translator to translate these code in machine language.
  • Examples of high level languages are C, C++, Java,FORTRAN etc.

Convert string UpperCase

Q. Write a string to accept string through keyboard and convert it Uppercase letter.

Ans.

/*program to convert a string in upper case letter*/
#include<stdio.h>
#include<string.h>
int main()
{

Convert string LowerCase

Q. Write a string to accept string through keyboard and convert it Lower Case letter.

Ans.

/*program to convert a string in lower case letter*/
#include<stdio.h>
#include<string.h>
int main()
{

12.23.2011

Number pattern

Q. Write a C program to display the following pattern:
 1
 2   3
 4   5    6
 7   8    9    10
11  12   13    14  15

Ans.

/*program to design the above pattern*/
#include<stdio.h>
#include<conio.h>
void main()
{

12.17.2011

goto statement

The goto statement is used to alter the normal sequence of program instructions by transferring the control to some other portion of the program.
The syntax is as follows:
goto label;
Here, label is an identifier that is used to label the statement to which control will be transferred. The targeted statement must be preceded by the unique label followed by colon.
label: statement;
It is recommended that as possible as skip the goto statement because when we use goto then we can never be sure how we got to a certain point in our code. They obscure the flow of control.

Note:- goto can never be used to jump into the loop from outside and it should be preferably used for forward jump.

Let us consider a program to illustrate goto and label statement:

Selection sorting

Q. Write a C program to to sort a list of elements using selection sort method.

Ans.

/*program to demonstration of selection method*/
#include<stdio.h>
#include<conio.h>
#define SIZE 10
int main()
{

Bubble sorting

Q. Write a program to accept 10 numbers from user and sort list using Bubble sorting method.

Ans.
Logic of bubble sorting as follows:


In bubble sorting steps:
1. Start from left hand side
2. Compare first two numbers
3. If first_number > second_number than swap both number position. And if first_number < second_number than these compare next two numbers i.e. second_number and third_number.
4. Step-3 process repeat until there are no more numbers left to compared.
5. Bubble sorting completed.

An example on bubble sort.
To understand logic of Bubble Sorting, lets take random numbers:

6  3  7  1  4  5  2

First iteration
6  3  7  1  4  5  2

6  7  1  4  5  2

3  6  7  1  4  5  2

3  6  1  7  4  5  2

3  6  1  4  7  5  2

3  6  1  4  5  7  2

3  6  1  4  5  2  7

Second iteration
3  6  1  4  5  2  7

6  1  4  5  2  7

3  1  6  4  5  2  7
3  1  4  6  5  2  7

3  1  4  5  6  2  7

3  1  4  5  2  6  7

12.10.2011

Palindrome function

Q. Write a C program to check whether a string is palindrome or not using function.

Ans.

/*Program to check whether a string is palindrome or not using function*/
#include<stdio.h>
#include<conio.h>
char string_palin(char str[]);
int main()
{

12.02.2011

String Triangle

Q. Write a program to display the string INDIA in the following fashion:

I
IN
IND
INDI
INDIA
INDIA
INDI
IND
IN
I

Ans.

/*program to display the string as given fashion*/
#include<stdio.h>
#include<conio.h>
int main()
{