Skip to main content

Hello World Example In C Programming | WaoFamHub

Hello World Example



A C program basically consists of the following parts −


  • Preprocessor Commands
  • Functions
  • Variables
  • Statements & Expressions
  • Comments


Let us look at a simple code that would print the words "Hello World" −

INPUT

#include <stdio.h>
void main {
   /* my first program in C */
   printf("Hello, World! \n");
   getch;
}

Let us take a look at the various parts of the above program −


  • The first line of the program #include <stdio.h> is a preprocessor command, which tells a C compiler to include stdio.h file before going to actual compilation.
  • The next line int main() is the main function where the program execution begins.
  • The next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program.
  • The next line printf(...) is another function available in C which causes the message "Hello, World!" to be displayed on the screen.
  • The next line return 0; terminates the main() function and returns the value 0.


Compile and Execute C Program

Let us see how to save the source code in a file, and how to compile and run it. Following are the simple steps −


  • Open a text editor and add the above-mentioned code.
  • Save the file as hello.c
  • Open a command prompt and go to the directory where you have saved the file.
  • Type gcc hello.c and press enter to compile your code.
  • If there are no errors in your code, the command prompt will take you to the next line and would generate a.out executable file.
  • Now, type a.out to execute your program.
  • You will see the output "Hello World" printed on the screen.


OUTPUT

Hello, World

Comments

Popular posts from this blog

Why Software Engineering is Popular? | WaoFamHub

Why Software Engineering is Popular? Here are important reasons behind the popularity of software engineering: Large software – In our real life, it is quite more comfortable to build a wall than a house or building. In the same manner, as the size of the software becomes large, software engineering helps you to build software. Scalability - If the software development process were based on scientific and engineering concepts, it is easier to re-create new software to scale an existing one. Adaptability : Whenever the software process was based on scientific and engineering, it is easy to re-create new software with the help of software engineering. Cost - Hardware industry has shown its skills and huge manufacturing has lower the cost of the computer and electronic hardware. Dynamic Nature - Always growing and adapting nature of the software. It depends on the environment in which the user works. Quality Management : Offers better method of software development to provide quality so...

Bresenham’s Line Drawing Algorithm Program In C | WaoFamHub

Bresenham’s Line Drawing Algorithm Program In C INPUT #include<stdio.h> #include<graphics.h> void drawline(int x0, int y0, int x1, int y1) { int dx, dy, p, x, y; dx=x1-x0; dy=y1-y0; x=x0; y=y0; p=2*dy-dx; while(x<x1) { if(p>=0) { putpixel(x,y,7); y=y+1; p=p+2*dy-2*dx; } else { putpixel(x,y,7); p=p+2*dy; } x=x+1; } } int main() { int gdriver=DETECT, gmode, error, x0, y0, x1, y1; initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi"); printf("Enter co-ordinates of first point: "); scanf("%d%d", &x0, &y0); printf("Enter co-ordinates of second point: "); scanf("%d%d", &x1, &y1); drawline(x0, y0, x1, y1); getch(); } OUTPUT

Draw A Simple Hut On The Screen Program In C | WaoFamHub

A Simple Hut On The Screen INPUT #include<graphics.h> #include<conio.h> int main(){ int gd = DETECT,gm; initgraph(&gd, &gm, "C:\\TURBOC3\\BGI"); setcolor(WHITE); rectangle(150,180,250,300); rectangle(250,180,420,300); rectangle(180,250,220,300); line(200,100,150,180); line(200,100,250,180); line(200,100,370,100); line(370,100,420,180); setfillstyle(SOLID_FILL, BROWN); floodfill(152, 182, WHITE); floodfill(252, 182, WHITE); setfillstyle(SLASH_FILL, BLUE); floodfill(182, 252, WHITE); setfillstyle(HATCH_FILL, GREEN); floodfill(200, 105, WHITE); floodfill(210, 105, WHITE); getch(); closegraph(); return 0; } OUTPUT

AMP Website VS Normal Website | WaoFamHub

AMP Site VS Normal Site What Is AMP Site? AMP (originally an acronym for Accelerated Mobile Pages) is an open source HTML framework developed by the AMP Open Source Project. It was originally created by Google as a competitor to Facebook Instant Articles and Apple News. AMP is optimised for mobile web browsing and intended to help webpages load faster. What Is Website? A website (also written as web site) is a collection of web pages and related content that is identified by a common domain name and published on at least one web server. ... Websites are typically dedicated to a particular topic or purpose, such as news, education, commerce, entertainment, or social networking. Whay AMP Site Load Fast? AMP-built web pages have a lightning bolt indicator in the search result. This is what an AMP page looks compared to a normal web page: The reason why AMP pages load instantly is because AMP restricts HTML/CSS and JavaScript, allowing faster rendering of mobile web pages. How To Make AMP ...

What Is Google Schemas? And Types | WaoFamHub

Google Schema What is Google Schema? (V1) Schema.org (often called Schema) is a semantic vocabulary of tags (or microdata) that you can add to your HTML to improve the way search engines read and represent your page in SERPs. What Is Google Schemas ? (V2) Website Schemas are essentially words or tags in a “shared vocabulary” that can be used by your on-line marketing company (like us!) to talk to search engines like Google & Bing to provide refined searches. What Is Google Schemas? (V3) Schema markup, also known as structured data, is the language of search engines, using a unique semantic vocabulary. It is code used to more clearly provide information to search engines in order to understand your content. In turn, this helps provide users with better, more accurate information in the rich snippets that are displayed beneath the page title. What is schema and why is it important? Schema is powerful and important. By being able to implement and use this information. You'll not o...

What Is C Programming? | Why To Learn C Programming | WaoFamHub

What Is C Programming C programming is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system. C is the most widely used computer language. It keeps fluctuating at number one scale of popularity along with Java programming language, which is also equally popular and most widely used among modern software programmers. Why to Learn C Programming? C programming language is a MUST for students and working professionals to become a great Software Engineer specially when they are working in Software Development Domain. I will list down some of the key advantages of learning C Programming: Easy to learn Structured language It produces efficient programs It can handle low-level activities It can be compiled on a variety of computer platforms Facts about C C was invented to write an operating system called UNIX. C is a successor of B language which was introduced aroun...