Hello world Program and Basic Arithimetic Operations Program in C

In this tutorial we shall start learning Programming through C.As a basic program of every programming language we shall start with Hello world program and some basic arithmetic program.

For a Hello world we need to just display the “Hello world” to user.For this we shall use printf statement which we explained in our earlier post.As we are using an output statement we include stdio.h header statement.
The program of Hello World is:

#include<stdio.h>
void main()
{
  printf("HELLO WORLD");
}

OUTPUT:

HELLO WORLD

This is how we need to use the input/output statement in body of a program.Now we shall write a program to perform all the basic arithmetic operation on inputs given by user using scanf() statement.The flow of the program is:
1.We need to get two values from the user.
2.Perform all basic arithmetic operation such as: addition,subtraction,multiplication,division.
3.Display those output values to the user with respective text display.
The main important point in usage of division is we get the remainder as an output of division performed.
Now we shall write the code basing on above guidelines:

#include<stdio.h>
void main()
{
  int x,y;   //Declaration of integer type variables
  int add,sub,mul,div;
  printf("\n  Enter first integer value as an input:");
  scanf("%d",&x);  //Getting the value from user and storing it in x.
  pirntf("\n  Enter second integer value as an input:");
  scanf("%d",&y);  //Getting the value from user and storing it in y.
  add = x+y;
  sub = x-y;
  mul = x*y;
  div = x/y;
  printf("\n  Addition of given two numbers is:%d",add);
  printf("\n  Subtraction of given two numbers is:%d",sub);
  printf("\n  Multiplication of given two numbers is:%d",mul);
  printf("\n  Division of given two numbers is:%d",div);
}

OUTPUT:
arithimetic
You can download the arithmetic program:download

Advertisement

About Anuroop D

Very enthusiastic about technology and likes to share my knowledge through blogging. Has Bachelor's in Information Technology and currently pursuing my PhD in Computer Science.
This entry was posted in C and tagged , , , , , , , , , . Bookmark the permalink.

1 Response to Hello world Program and Basic Arithimetic Operations Program in C

  1. novie testi says:

    I’m pretty pleased to discover this page. I need to to thank you for
    your time just for this fantastic read!! I definitely loved every little bit
    of it and I have you bookmarked to see new stuff on your web site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s