Friday, August 26, 2011

Interesting Programs at beginner stage


1. Write a c program without using any semicolon which output will : Hello word.

2. Swap two variables without using third variable.

Solution: 1
void main(){
    if(printf("Hello world")){
    }


Solution: 2
int main(){
    int a=5,b=10;
//process one
    a=b+a;
    b=a-b;
    a=a-b;
    printf("a= %d  b=  %d",a,b);
//process two
    a=a^b;
    b=a^b;
    a=b^a;
    printf("\na= %d  b=  %d",a,b);  



 
Good Collection of C Programs for beginner: http://cquestionbank.blogspot.com/2010/07/c-program-examples.html
  

Good example on OOPs concept in C++
http://www.functionx.com/cpp/examples/index.htm 

No comments:

Post a Comment