Translate

Saturday, 22 March 2014

ASCII standard codes used in programming and many more application

Brief History of ASCII code:


The American Standard Code for Information Interchange, or ASCII code, was created in 1963 by the "American Standards Association" Committee or "ASA", the agency changed its name in 1969 by "American National Standards Institute" or "ANSI" as it is known since.

This code arises from reorder and expand the set of symbols and characters already used in telegraphy at that time by the Bell company.

At first only included capital letters and numbers , but in 1967 was added the lowercase letters and some control characters, forming what is known as US-ASCII, ie the characters 0 through 127.
So with this set of only 128 characters was published in 1967 as standard, containing all you need to write in English language.

In 1981, IBM developed an extension of 8-bit ASCII code, called "code page 437", in this version were replaced some obsolete control characters for graphic characters. Also 128 characters were added , with new symbols, signs, graphics and latin letters, all punctuation signs and characters needed to write texts in other languages, ​​such as Spanish.
In this way was added the ASCII characters ranging from 128 to 255.

IBM includes support for this code page in the hardware of its model 5150, known as "IBM-PC", considered the first personal computer.
The operating system of this model, the "MS-DOS" also used this extended ASCII code.
Almost all computer systems today use the ASCII code to represent characters and texts. (147) .

The ASCII , character codes normally used in programming are given below, with the help of these codes you can print in case character without have to actually write the character, although they dont seem so useful but its applications are present





Introducing The Scanf Function

Scanf :

The scaf function is an input function , that take the input for the value for the character types in c programming, saves in the the memory address of that dada type and perform action or other implementation on it 
The syntax for the function is
Scanf("%d or %c , ( of the data type you are taking) ",$...of the value you want it to be stored in);


for example, if we are taking an integer and storing its value in a.
then :
scanf("%d",&a);



A basic program to introduce the function :



#include<stdio.h>
#include<conio.h>
void main(void)
{
int a,b,s;
clrscr();
printf("Enter the value for a: ");
scanf("%d",&a);
printf("\nEnter the value of b: ");
scanf("%d",&b);
s=a+b,
printf("\nThe answer after adding is : %d\n\n\n\n\tProgram made by programmer Sami Ullah",s);
getch();
}

In this we took three sets of integers a , b and s , int a we stored the value of 'a' and in int b we stored the value of 'b' and then we took an other integer where we stored the value of there sum and applying the sum formula on "a+b" and assigning the int s its value.


Make a simply calculator using Turbo c++ ( Scanf function not introduced )

Source Code :

#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
  printf("\t\t\t\tCALCULATOR");
  printf("\n\t\t\t\t**********");
  printf("\n\n\tFirst # = %d  ,",12);
  printf("\tSecond # = %d",6);
  printf("\n\n\n\t\t\t    Arithmetic Operations");
  printf("\n\t\t\t    +++++++++++++++++++++");
  printf("\n");
  printf("--------------------------------------------------------------------------------");
  printf("\t* 1. Addition =");
  printf("\t\t%d+%d=\t%d",12,6,12+6);
  printf("\n\t* 2. Subtraction =");
  printf("\t%d-%d=\t %d",12,6,12-6);
  printf("\n\t* 3. Multiplication =");
  printf("\t%d*%d=\t%d",12,6,12*6);
  printf("\n\t* 4. Division =");
  printf("\t\t%d/%d=\t %d",12,6,12/6);
  printf("\n--------------------------------------------------------------------------------");

 getch();  }


In this program we simply took hard coded number for the values to be added,subtracted,multiplied and devide .




Program to print the set of even numbers in Turbo c ++

Source Code :

#include<stdio.h>                                                                            
#include<conio.h>                                                                          
void main(void)                                                                               
{                                                                                                       
int a;
clrscr();
a=0;
printf("\n\t%d",a);
a+=2;
printf("\n\t%d",a);
a+=2;
printf("\n\t%d",a);
a+=2;
printf("\n\t%d",a);
getch();
}

In this we used the increment factor " a+=2" , that mean from the original value of "a" add two to the number and print it, and we assigned the original value of "a" a=0 , so after each line the factor adds +2 to the original a=0 and prints it. like 0,2,4.......
The sample program looks something like this 




Friday, 21 March 2014

Extracting signal digit numbers from a set of signal code with several digits

Source Code :

#include<stdio.h>
#include<conio.h>
void main(void)
{
int no,a,b,c,d,e,f,sum14,sum12,sum13,pro12,pro14,pro13,sub12,sub13,sub14;
float div12,div13,div14;
clrscr();
printf("Enter a 4 digit number:");
scanf("%d",&no);
printf("\n\t Extracing singal digits from a code");
printf("\n\t-------------------------------------");
a=(no/1000);
b=(no%1000);
c=(b/100);
d=(b%100);
e=(d/10);
f=(d%10);
sum14=(a+f);
sum12=(a+c);
sum13=(a+e);
pro14=(a*f);
pro12=(a*c);
pro13=(a*e);
sub14=(a-f);
sub12=(a-c);
sub13=(a-e);
div13=(a/e);
div12=(a/c);
div14=(a/f);
printf("\nThe first number is : %d",a);
printf("\nThe second number is : %d",c);
printf("\nThe third number is : %d",e);
printf("\nThe Fourth number is : %d",f);
printf("\n\nThe sum of the first and the last numbers are : %d",sum14);
printf("\nThe sum of the first and the second numbers are : %d",sum12);
printf("\nThe sum of the first and the third numbers are : %d",sum13);
printf("\n\nThe product of the first and the last numbers are : %d",pro14);
printf("\nThe product of the first and the second numbers are : %d",pro12);
printf("\nThe product of the first and the third numbers are : %d",pro13);
printf("\n\nThe subtract of the first and the last numbers are : %d",sub14);
printf("\nThe subtract of the first and the second numbers are : %d",sub12);
printf("\nThe subtract of the first and the third numbers are : %d",sub13);
printf("\n\nThe devide of the first and the last numbers are : %.2f",div14);
printf("\nThe devide of the first and the second numbers are : %.2f",div12);
printf("\nThe devide of the first and the third numbers are : %.2f",div13);
getch();

}