A Simple C Program

Hello Friends,

This is a very simple C Program demonstrating input, output using printf(), scanf() functions in C. It also shows how to write and call some simple functions in C without any argument or return type.

Level- Beginner

  Program demonstrating Simple Functions, input, output in C

Hello.c


#include<stdio.h>
#include<conio.h>

void hello_message()
{
     printf("\n Hello World!! :)\n");
}

void bye_message()
{
     printf("\n Good Bye World!!!\n");
}

void main()
{
     int num, a, b, c;
     a=5;
     b=7;
     printf("\n ~~~Welcome to the world of C~~~ \n");
     /*
     This is not allowed gives error
     printf("\n Hello

     ");*/

     hello_message();

     printf("\n Enter a Number : ");

     scanf("%d", &num);

     printf("\n You entered %d", num);

     printf("\n c = %d (Garbage Value)", c); //displays garbage value
     c=9;
     printf("\n c = %d", c);//o/p - 9
     printf("\n a = %d", a); //o/p - 5

     printf("\n Experiments with printf \n");

     printf("\n number = %d", 3); // o/p- 3
     printf("\n a+b = %d", a+b); //o/p -12
     printf("\n a*b+c = %d", a*b+c); //o/p-44

     printf("\n Experiments with scanf \n");

     printf("\n Enter three Numbers : ");
     scanf("%d %d %d", &a, &b, &c);
     printf("\n a = %d, b = %d, c = %d ", a,b,c);

     printf("\n Enter three Numbers (separated by commas) : ");
     scanf("%d, %d, %d", &a, &b, &c);
     printf("\n a = %d, b = %d, c = %d ", a,b,c);

     bye_message();
     getch();
}

 Snapshot of the o/p

Simple Program O/P

Advertisements

One thought on “A Simple C Program

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 )

Google+ photo

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

Connecting to %s