C Programming Tutorial

 

Printf

The printf statement allows you to send output to standard out(Computer Screen). 
Here is another program that will help you learn more about printf:

#include <stdio.h>

int main()
{
    int d, e, f;
    d = 5;
    e = 7;
    f = d + e;
    printf("%d + %d = %d\n", d,e,f);
    getchar();
    return 0;
}


Here save the file as Second.c. Compile and Run the program.

Explanation:
The line int d, e, f; declares three integer variables named d, e and f. Integer variables hold whole numbers.
The next line initializes the variable named d to the value 5.
The next line sets e to 7.
The next line adds d and e and "assigns" the result to f.

The computer adds the value in d (5) to the value in e (7) to form the result 12, and then places that new value (12) into the variable f. The variable f is assigned the value 12. For this reason, the = in this line is called "the assignment operator."

The printf statement then prints the line "5 + 7 = 12." The %d placeholders in the printf statement act as placeholders for values. There are three %d placeholders, and at the end of the printf line there are the three variable names: d, e and f. C matches up the first %d with d and substitutes 5 there. It matches the second %d with e and substitutes 7. It matches the third %d with f and substitutes 12. Then it prints the completed line to the screen: 5 + 7 = 12. The +, the = and the spacing are a part of the format line and get embedded automatically between the %d operators as specified by the programmer.

 

Microcontroller

What is a Microcontroller?

Microcontroller Specification

Programming PIC16F877A

Playing with a C Programming and PIC16F877A

Creating a Digital Clock using PIC16F877A, LCD and DS1337 Clock IC from Dallas

How to Load Hex File into PIC16F877A

 

Articles :

Lightning Surge Testing

Bit Error Rate Testing

Insertion Loss Testing

 

Light Emitting Diode

DC Power Jack

Voltage Regulator and Diode

Transistor and Operational Amplifier

Trimmer Pot, Relay and PCB

 

Understanding PIC16F877A

Product Development Using PIC16F877A

More Product Development Using PIC16F877A

PIC16F877A Input Output Overview

Interfacing PIC16F877A With LCD

 

VoIP Basic

VoIP Phone

Using VoIP Through Normal PSTN Telephone

What is Codec?

 

C Programming Tutorial

Introduction

What is C programming language?

The First C Program

The First C Program - Explanation

Variables

Printf

Reading User Values

Scanf

Looping

Using FOR loop

Arrays

More on Arrays

Example Program that use Arrays to Compare 6 PIN number

If, Else If, Else

Functions

Pointers

Summary

 

 

 

 

 

 

 

 

 

 

 

Copyright www.electronics.netmyne.com.