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();

}




Source Code :

#include<stdio.h>
#include<conio.h>
void main(void)
{
char a,b;
clrscr();
a=getch();
printf("The character you pressd was: %c",a);
b=a-32;
printf("\nThe character converted is : %c\n\n\n\n\t\t\t\tProgram made by Programer Sami ullah ",b);
getch();
}


We know the code for Capital " A " is 65 and small "a" is 97
so if you take small "a" in terms of code as input and minus 32 from the code that leaves you with 65 the code for capital " A " . so you just print the code in terms of character.
Note [ this can be applied for general ]
the sample program look like this..








Just my Life and the life of every awesome programmer  :D


P.s Programming is just LoVe .. #thelovefeels ^^







Program to print English alphabets in order using increment factor


Source Code :


#include<stdio.h>
#include<conio.h>
void main(void)
{
char a;
clrscr();
a=65;
printf("The first character is  : %c",a);
a++;
printf("\nThe second character is : %c",a);
a++;
printf("\nThe third character is  : %c",a);
a++;
printf("\nThe forth character is  : %c",a);
a++;
printf("\nThe fifth character is  : %c",a);
getch();
}


Here we used the increment factor to produce ( A,B,C.............)
you know the ASCII codes for the English alphabets, used that logic to create a simple program.
what we did here is that assigned a=65 , which is the code for Capital alphabet 'A' and used increment to increase the number to 66,67 which are the codes for capital B,C ... so on respectively and print using the %c  [ note if you use %d to print , it will just print the number 66.67..... ]


The sample program looks something like this.




Make A simple increment number program through Turbo c ++

Source Code :

#include<stdio.h>
#include<conio.h>
void main(void)
{
int a;
clrscr();
a=1;
printf("The original value of a : %d",a);
a++;
printf("\nThe first increment : %d", a);
a++;
printf("\nThe second increment : %d", a);
a++;
printf("\nThe third increment : %d", a);
a++;
printf("\nThe fourth increment : %d", a);
getch();
}

The increment factor used here is a++ , which auto assign the original value of a with a +1 addition,in each line the value of a gets and increment by 1, because of the statement a++
and the we can print the increment in each line ..
here is the sample of what the program looks like 




First time Experience the awesomeness of programming

Woohh, wth... omg it has come to liFe :D
that was me when i first laid hand on C . momy moMy the computer actually respond to me now :D
no more sitting dumb and letting the computer contol you I control you now .. ** :D

And since that day, i live in the pure A.I word now, Keep calm and let the codes run ....




Programming is Fun ..

Here are some very interesting programming facts about computer field and programming language .  Share with your friends for more fun.


  • The first computer programmer was a female, named Ada Lovelace.
  • The first game was created in 1961
  • The first virus was created in 1983
  • The first computer was actual a loom called the Jacquard loom, an automated, mechanical loom, which didn’t use any electricity.
  • The first high-level (very close to real English that we use to communicate) programming language was FORTRAN. invented in 1954 by IBM’s John Backus.
  • Computer programming is one of the fastest growing occupations currently
  • Majors related to computer programming are among the highest paying in colleges and universities A programming language is basically a language that allows a human being to communicate with a computer The lifestyle we live today with our tablets, and mobile phones wouldn’t be possible without computer programming
  • Most people are intimidated by the thought of learning how to program, however as with anything, the more you practice and repeatedly do that task, the easier it gets.

Thursday, 20 March 2014

A fellow programmer's blog
working with me and soon to bring more codes on various things 

http://tabishprogrammer.blogspot.com/
I am having my midterm exams now a day, and its completely like the situation i dont know a thing in paper, and the last night i was like ... To man i can take this paper so easy xD then hahaha. WTH is thiS .
i am Screwed up :p
Ever ! had the feeling x.X .........
Programming is the only thing i am good at now x. + that is just in the brain, so you can never get it wronG



You may never know what mistake you made, its like completely rare that you made something and you know why that thing is working :D ,
Say Hello to the goood old C ++ ... where You Never Know what you did wronG xD




Wednesday, 19 March 2014

A simple " Text based game " can refer to as a basic Rpg type game, made using simple steps and choices.

Source Code :

#include<stdio.h>
#include<conio.h>
void main(void)
{
int a,b;
clrscr();
printf("You see a door , a voice calls ........ do you want to ent..e..r..The voice \nslowly fades away..\nwhat would you like to do .? press 1 to enter and press o to ignore\n\n press 0 and enter, the if condidtion for 1 is still in making by sami");
scanf("%d",&a);
clrscr();
if(a==1)
b=printf("\nYou entered and a text is written on the wall , ... \n would you like to read it . if you want to read it press 2 otherwise 3. to \nignore and move forward");
else
{
a==0;
printf("\n....You went back home and tried to forgot about that strage voice\npress o and enter to continue\n\n then when you done compile again repeat till this step and press any other \nnumber other then 0 :) ");}
scanf("%d",&a);
clrscr();
if(a==0)
printf("\n\n This is the End\nprogramm under contruction, thanks for checking ^^");
else
{
clrscr();
printf("\n\n\n\n\n  do as you are told , i told you to press 0 .-----. "); }
getch();


}



Simple steps to show how this little text based game work. basically its takes input as a number, 

i have predefined the coding that what will the the effect of the key pressed 





A simple " print " program in Turbo c or c++

Source Code :

for the new bolg i feel a simple program should be made 



#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
printf("\t\t\t\tHello This my new blog");
getch();

}
Getting into programming, so here is a new blog, if you are into programming and game designing this will prove helpful.I have done a lot of programs as well worked on some game designs as well . i like to share my ideas and practice more into game designing