Introduction To Programming

Why programs ? Programming is nothing but making the computers think the same way a human thinks. Programs are made for obtaining a specific solution which can even be solved by humans which when solved by us may consume time..

Saturday, April 24, 2010

Additon without Arithmetic Operators:

Here is the program which use bit wise operator and perform the addition operation. There is no arithmetic operator is used in this program.

int main()
{
int a,b,sum,carry;
printf("Enter the values");
scanf("%d %d",&a,&b);
sum=a^b;
carry=a&b;
while(carry!=0)
{

Program without Header File

is it possible to run the program without header file?  yes, it is possible.  consider the following program.

int main()
{
printf("hi");
return 0;
}
 It will work perfectly ,if you save the file.  But the concept is that while compiling itself ,compiler includes stdio.h header file automatically. 

Predict the Output:

int main()
{
fprintf(stdout,"Hello");
return 0;
}
 Answer:


Error,stdout is undeclared
Hello will be printed in console
Hello will be print in stdout.c file

Will it work?

#include<string.h>
int main()
{
printf(strcat("www.newtech4u.co.cc","!");
return 0;

}

exit Function:

This article will teach you what the exit function does.


Definition of exit Function:
exit function terminates the program process. It is called as "exit(error_status)"
 consider this following program:
 #include<stdio.h>
#include<stdlib.h>

Difference between Normal function and Macro Funcion

Normal function is defined :
return_type function_name(arguments)
{
//coding
}
Macro function:
#define funtion_name(arguments) coding

Difference:
while compiler expanding the code, the macro function is replaced in called place, but normal function is just called by . 


Macro function example source code and expanded code:

Source Code:
#define tech() printf("hi")
int main()

Run the coding after exiting main function

Do you think that it is possible to run the code after exiting main function? Yes ,it is possible to run the codes after exiting main function also.

Consider this Simple Program:
#includ<stdio.h>
#include<stdlib.h>
void after_main()
{

Pointer vs Array

Let you teach what is difference between pointer and array. Firs of all we should know the definition of pointer and array.

Pointer:
Pointer is a variable that capable of storing the address
Array:
Array is collection of same elements

Difference between #include and #include "stdio.h"

Many of you confused with this two method of specifying the include files. This article will teach you what the difference between these two is.

#include <stdio.h>

This method of specifying is used to include the standard header files.