Saturday 24 December 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:

  1. C programming language behaves as high level language through function, it gives a modular programming and breakup, increased the efficiency for resolvability. 
  2. C programming language support the low level language i.e. Assembly Language.
  3. C language also gives the facility to access memory through pointer.
  4. Its combines the elements of high-level languages with the functionalism of assembly language.
So, C language neither a High Level nor a Low level language but a Middle Level Language.

Learn also:
  1. What is the use of C program in real life?

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.
Learn also:
  1. What is High Level Language?
  2. Why C is called Middle Level Language?
  3. What is the use of C programs in real life?

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.
Note: FORTRAN is first High Level Language.


Learn also :
  1. What is Low Level Language?
  2.  Why C is called middle level Language?

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()
{
 char str[40];
 int i;
 printf("Enter any string : ");
 gets(str);
 for(i=0; str[i]!=NULL; i++)
 {
   if(str[i]>='a' && str[i]<='z')
   {
      str[i]=str[i]-32;
   }
 }
 str[i]='\0';
 puts(str);
 getch();
 return 0;
}

Output:-

Enter any string : My C ProgrammING CodeS
MY C PROGRAMMING CODES

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()
{
 char str[40];
 int i;
 printf("Enter any string : ");
 gets(str);
 for(i=0; str[i]!=NULL; i++)
 {
    if(str[i]>='A' && str[i]<='Z')
    {
       str[i]=str[i]+32;
    }
 }
 str[i]='\0';
 puts(str);
 getch();
 return 0;
}

Output:-
Enter any string : My C ProgrammING CodeS
my c programming codes

Friday 23 December 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()
{
 int r,c,n=1;
 clrscr();
 for(r=1; r<=5; r++)
 {
  for(c=1; c<=r; r++)
  {
    printf("%3d",n++);
  }
  printf("\n");
 }
 getch();
}

Output:-

 1
 2   3
 4   5    6
 7   8    9    10
11  12   13    14  15

Tuesday 20 December 2011

Reverse Floyds Triangle

7 8 9 10
4 5 6
2 3
1


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
i=7;
for(j=3;j>=0;j--)
{
for(k=0;k<=j;k++)
{
printf("%d ",(i+k));
}
i=i-j;
printf("\n");
}
getch();
}

Check Leap Year in C++


//Write a program to check whether the year is leap or not
#include <iostream.h>
#include <conio.h>
void main ()
{
int y;
clrscr ();
cout <<"Enter Year: ";
cin >>y;
if (y%4==0)
{
cout <<"Year is Leap";
}
else
{
cout <<"Year is not Leap";
}
getch ();
}

Calculate bill with discount in C++


/*Enter Quantity and cost, Calculate total Bill According to the Following Condition:
if bill is greater than 200 then 2% discount
otherwise give 3% discount */

#include <iostream.h>
#include <conio.h>
void main ()
{
int bill, disc, total, qty, cost;
cout <<" Enter Quantity: ";
cin >>qty;
cout <<" Enter Cost: ";
cin >>cost;
bill=qty*cost;
if (bill>200)
{
disc=bill*2/100;
}
else
{
disc=bill*3/100;
}
total=bill-disc;
cout <<"Total Bill After Discount: "<<total;
getch ();
}

Check Odd or Even Number in C++


//Write a program to find whether number is odd or even.
#include <iostream.h>
#include <conio.h>
void main ()
{
int a;
clrscr ();
cout <<"Enter Any Number: ";
cin >>a;
if (a%2==0)
{
cout <<"Number is Even";
}
else
{
cout <<"\n Number is Odd;
}
getch ();
}

Find Greater between two numbers in C++


//Write a program to find greater between two numbers
#include <iostream.h>
#include <conio.h>
void main ()
{
int a,b;
clrscr ();
cout <<"Enter A: ";
cin >>a;
cout <<"Enter B: ";
cin >>b;
if (a>b)
{
cout <<"A is Greater";
}
else
{
cout <<"B is Greater";
}
getch ();
}