Tag Archives: Basic Programs

C Program for Declaring a variable and Printing Its Value

In this tutorial, we will learn to create a program where we will be declaring a variable and printing its value using C programming language.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • C Variables
  • C Data Types
  • C Input Output

Program for Declaring a variable and Printing Its Value

In this program, we will declare both integer and floating type variables and print their values using printf function.

Output:-

C-Program-for-Declaring-variable-and-Printing-Its-Value

In the above program, we have first declared and initialized a set of both integer and floating type variables.

  • a = integer type variable initialized with 5
  • b = integer type variable initialized with 10
  • c = float type variable initialized with 5.2
  • d = float type variable initialized with 20.5

In the next section we have some printf statements to print values of the integer variables using integer format specifier(%d) and values of float variables using float format specifier(%f).

C Program to Print Hello World Multiple Times

In this tutorial, we will learn to create a program to print “Hello World” multiple times using for loop C programming language.You can also use While Loop, or Do While to do the same task.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C programming topics:

  • C printf
  • C for loop
  • C while loop
  • C do while loop

Program to Print Hello World Multiple Times

In this program we will print “Hello World” multiple time using for loop. We would first declared and initialized the required variables. Next, we would prompt user to input number of time you want print “Hello World”. Later we will print same “Hello World” string for number of time input by user.

Output:-

c-program-to-print-hello-world-multiple-time-using-for-loop

In the above program, we have first declared and initialized a set variables required in the program.

  • n = take number by user to print message.
  • i = iterator to loop through.

In the next statement user will be prompted to enter a number which will be assigned to variable ‘n’. Now we will loop through the iterator ‘i’. Inside the for loop we have print statement to print “Hello World. This will be repeated until it print “Hello World” required number of times.

C Program To Print Hello World

C Program To Print Hello World

The C “Hello World” program is a simplest program that will display some text on the screen. The C “Hello world” program is a simple yet complete program for beginners that illustrates the basic syntax of any programming language. The C “Hello world” program gives you a way to test systems and programming environment. Let’s have a look at the program first.

Note:- The printf() is a function that tells C Compiler to display or output the content inside the parentheses.

Output:-

c_program_to_print_hello_world