Tuesday, February 18, 2014

programs in c

Print "Hello" in C Program

# include <stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf ("Hello.....");
getch();
}

Result: Hello......


Add Two Numbers In C:

# include <stdio.h>
#include<conio.h>
void main()
{
clrscr();
int first_num,second_num,sum;
first_num=10;
second_num=20;
sum=first_num+second_num;
printf("%d The Sum is=", sum);

getch();
}

Result:The Sum is=30


OR
# include <stdio.h>
#include<conio.h>
void main()
{
clrscr();

int first_num,second_num,sum;
printf("Enter the First Number= ");
scanf("%d",&first_num);
printf(Enter the Second Number=");
scanf("%d",&second_num);
sum=first_num+second_num;
printf("%d The Sum is=", sum);

getch();
}

Result:
Enter the First Number=30
Enter the Second Number=20
The Sum is=50

No comments:

Post a Comment