Sunday, January 29, 2012

Adding Timer in C code

Hello everyone! Hope you are passing great time with coding!!
Today I am here with how to add or insert a timer in your C code to show the time how much your code taking time to execute. Sometimes it becomes important to see time your code taking. Okay let’s do it…
We will discuss with a very simple problem. User input two integers and a code to add them !!!
-----------------------------------------------------------------------------------------------------------------
Inserting timer:

#include <stdio.h>
#include <time.h>  //inserting time.h library function.

int main ( )
{
    int a, b, add;  //a & b two integers and add is their addition.
scanf ( “ %d %d ”, &a, &b ); // taking input.

clock_t start=clock(); // clock starting.
add = a + b; //adding a & b.

printf(“\nAddition of %d & %d is =  %d, a, b, add );
                      //printing result.
printf("\nTime = %.2f secondes\n",(double)(clock()-start)/CLOCKS_PER_SEC); // printing time.
    return 0 ;
-----------------------------------------------------------------------------------------------------------------
Inserting current time:
#include <stdio.h>
#include <time.h>

int main(void)
{
    time_t timer = time(NULL);
    printf("current time is %s", ctime(&timer));
    return 0;
}
-----------------------------------------------------------------------------------------------------------------
Reference:  

Sunday, January 22, 2012

Active AIUB Student Mail


There is a rumor among AIUBians as well as outsiders, that AIUB provide student mail only for AIUBians with 10GB (+25GB by Live) free space.
But it’s not rumor… it’s 200% true. Now problem is that how can someone active this student mail? I asked some seniors about this in my first semester but most of them said they only know about it, don’t  know how to activate. No probs. I am going to write about it.

Follow these steps:
Step 1:
Go to IT department in Level 5, Campus 4. Contact the duty stuff and collect a form. Write your name, ID, reason (for this mark on 'e-mail')and a valid e-mail address. The next day collect your password.
Step 2:
this PDF file & follow the next procedure to active student mail.
FINISH !!!

Hope this will beneficial for AIUBians.
Enjoy your stay on this blog.
ENJOY SAFE COMPUTING.
Thank you.

Tuesday, January 17, 2012

Beginners C Programming : Variables & Data Types


The Journey Begins
I always thought to do something for the beginners, to make those lessons easier which gave me lots of pain. (:P) So, the journey begins from here. Actually, today I attended my first class of C++. The discussions will be on C++. But before that I would like to review some chapters for the beginners so that those terms became easy for them as well as for them also who are practicing C.

Why do we have to learn a programming language??
Simply, we came to learn about the computer because we love computer, that what I realized and also told by my favorite course teacher. And a programming language is a language to communicate with the computer. (hmm… In a simple line.)

What is C or Why C?
The C is called the mother of programming language, the root or base level language, developed by Dennis Ritchie (September 9, 1941 to October 12, 2011). For detail, take a tour to the Wikipedia.
C is one of the most widely used computer language. It is a procedural or step by step procedure language.

Please Note: Don’t panic. I don’t want to make it lengthy. Search the web if you want. I like to make it short as possible but more useful.

Okay, it’s time now! Let’s get into C!!
Before that, we must to be familiar with some definitions which are so much important.

Variable & Data Type:
This is the first thought of a programming language.

Variable:
We have used some variables in Math. We imagined some ‘x’ or ‘y’ to prove a problem. Finally the ‘x’ or ‘y’ had a value. Our variable is also like that. A variable is that, which can store a value. Finish!!!
Tips: Your variable should be any alphabet (uppercase or lowercase), any word (like ‘sum’), and any combination of alphabets (like ‘aa’). Do not use ‘space’ in your variable.

Data Type:
Now read attentively.
How many students are there in your section? Look carefully at them and you will find them their characteristics will not match with each other, even yours. Everyone have different personality. Isn’t it?
If the students are your variables then their personality or characteristics are their Data Type. Clear? I think No. Data Type of a variable is that which represents the type of the variable like ‘x’ is a integer number or real number or a character. This is important that your variable must contain a valid Data Type.

Some of the Data Types used in C are:
int (stands for integer numbers i.e like 3)
float (stands for real numbers i.e like 3.1416)
char (stands for character i.e like ‘a’)


Hope that it was easy for you to understand. You can mail me from my profile that is below Blog Archive.
Enjoy your stay on this blog.
ENJOY SAFE COMPUTING.
Thank you.
Thanks - Jajabor, 2014