Introduction to C


1.Hello World Program
#include<stdio.h>

 int main()
{
printf("Hello World!");
}


2.Program to add two numbers entered by the user
#include<stdio.h>

int main( ){
int a,b,c;
printf("Enter any two numbers:\n");
printf("Enter First number:");scanf("%d",&a);
printf("Enter Second number:");scanf("%d",&b);
c=a+b;
printf("The sum is: %d",c);
}


3.Concept of Function:
#include<stdio.h>

void sum();//Function prototype

void main()
{

sum();//Function call
}

void sum()//Function Definition
{
printf("good morning");
}








1 comment: