Thursday, 22 November 2012

Example:Basic C programs


By on 23:51

Now I discuss some sample cum simple programs of C language.

Q)Write a program to print "hello world"?

P: #include<stdio.h>    // optional in c
      void main()
     {
      printf("Hell World"); // print
     }
       
Q)Write a basic program to input 2 no.s and print its sum(using third variable).

P: #include<stdio.h>    
      void main()
     {
      int a,b,c;
      printf("enter value of a and b"); 
      scanf("%d%d",&a,&b);
      c=a+b;
      printf("sum=%d",c);
      }

                                                       Or

     #include<stdio.h>    
     void main()
     {
     int a,b,c;
     a=10;
     b=20;
     c=a+b;
     printf("sum=%d",c);
     }



If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...