Technocrat

  • Home

Monday, August 17, 2015

Basic Structure of a C Program

 Sumit Kar     August 17, 2015     No comments   

A C program generally has the following parts:
§  Preprocessor Commands
§  Functions
§  Variables
§  Statements & Expressions
§  Comments

Let us consider a C Program:
#include<stdio.h>
void main()
{
printf("Hello, World!");
}

Preprocessor Commands: These commands tells the compiler to do some preprocessing before executing the actual compilation. For example, “#include <stdio.h>” is a preprocessor command which tells a C compiler to include stdio.h file before going to actual compilation.

Functions:  These are main building blocks of any C Program. Every C Program will at least have one function which is a mandatory function called main() function. This function is prefixed with keyword int or void or any other datatype. This defines the return type of the function. For int main() the program will return an integer value to the terminal (system).
The C Programming language provides a set of built-in functions. In the above example printf() is a C built-in function which is used to print anything on the screen.

Variables: These are used to hold numbers, strings and complex data for manipulation.

Statements & Expressions: Expressions combine variables and constants to create new values. Statements are expressions, assignments, function calls, or control flow statements which make up C programs.

Comments: are used to give additional useful information inside a C Program. All the comments will be put inside /*...*/

Note
•C is a case sensitive programming language. It means in C printf and Printf will have different meanings.
•C has a free-form line structure. End of each C statement must be marked with a semicolon.
•Multiple statements can be on the same line.
•White Spaces (ie tab space and space bar ) are ignored.
•Statements can continue over multiple lines.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Get your hands dirty

 Sumit Kar     August 17, 2015     Basic     No comments   

The only way to learn a new programming language is by writing programs in it. The first program to write is the same for all languages: Print the words hello, world!
In C, the program to print ``Hello, world!'' is
#include <stdio.h>
main()
{
printf("Hello, world!\n");
}
Just how to run this program depends on the system you are using.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp

Basics of C

 Sumit Kar     August 17, 2015     Basic     No comments   

What Is C?
C is a highly flexible and adaptable language. Since its creation in 1970, it's been used for a wide variety of programs including firmware for micro-controllers, operating systems, applications, and graphics programming.

When was C developed?
C was developed at Bell Laboratories in 1972 by Dennis Ritchie along with Ken Thompson. Many of its principles and ideas were taken from the earlier language B and B's earlier ancestors BCPL and CPL.

Who is the inventor of C?
Dennis Ritchie invented C, the computer-programming language that underlies Microsoft Windows, the Unix operating system and much of the other software running on computers around the world. Mr. Ritchie was a longtime research scientist at Bell Labs, originally AT&T's research division.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
  •  WhatsApp
Newer Posts Older Posts Home

Pages

  • Home

Trending Now

  • Write a Program to Add two 3x3 Matrix using C
    #include<stdio.h> void main () { int a [ 3 ][ 3 ], b [ 3 ][ 3 ], s [ 3 ][ 3 ], i , j ; printf ( "Enter the values of ...
  • C program for Unit Conversion
    /* Convert Celsius to Fahrenheit */ #include<stdio.h> void main() {     float c,f;     printf("Enter the temperature in Celcius: ...
  • Addition of two numbers on Server sent from Client [TCP] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • Write a Program to Print the Truth Table of Basic Gates using C
  • Write a Program to Add two 5x5 Matrix using C
    #include<stdio.h> void main() {   int a[5][5],b[5][5],c[5][5];   int i,j;   for(i=0;i<5;i++)   {     printf("\nEnter elements ...
  • Using the concept of Inheritance write a C++ Program to calculate the area and perimeter of rectangle
    /* C++ Program to calculate the area and perimeter of rectangles using concept of inheritance. */ #include using namespace std; class Re...
  • Concatenation of two strings sent from Client on the Server - [ TCP ] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • 8085 Programming: Exchange the contents of memory locations
    Exchange the contents of memory locations 2000H and 4000H. Program 1: LDA 2000H : Get the contents of memory location 2000H into accumulator...
  • Calculate Depreciation using C
    #include<conio.h> #include<stdio.h> void main () { float sv , pv , dep ; int yos ; clrscr (); printf ( "Enter the pu...
  • 8085 Programming: 1's COMPLEMENT OF A 16-BIT NUMBER
    The 16bit number is stored in C050,C051 The answer is stored in C052,C053   LXI H,C050   MOV A,M   CMA   STA C052   INX H   MOV ...

Blog Archive

  • ►  2020 (1)
    • ►  May (1)
  • ▼  2015 (92)
    • ►  October (4)
    • ►  September (3)
    • ▼  August (3)
      • Basic Structure of a C Program
      • Get your hands dirty
      • Basics of C
    • ►  July (9)
    • ►  June (9)
    • ►  May (20)
    • ►  April (7)
    • ►  March (22)
    • ►  February (7)
    • ►  January (8)
  • ►  2014 (158)
    • ►  November (70)
    • ►  October (6)
    • ►  September (82)
Powered by Blogger.

Categories

C - Programming Java Programming Basic Technology 8085 Assembly Programming For Loop Numerical Methods WhatsApp Algorithm Shell Programming Programming Networking Windows Android C++ Programming CPP If Else Tricky Internet Microsoft Pattern Photography Socket Program News While Loop Array DBMS DS Macro Recursion User Defined Function Conditional Operator Data Structure Durga Puja Earthquake Google Mela Nokia SQL Share Yahoo Airtel Bio Command Prompt Confused Facebook Finance Firefox Ganges Graph HokKolorob Input Kolkata MCQ Math Matrix NetNeutrality Oracle Religion Search Sumit Kar Survey Switch Case Viral Virus Visual Studio do-while featured featured_slider

Popular Programs

  • Write a Program to Add two 3x3 Matrix using C
    #include<stdio.h> void main () { int a [ 3 ][ 3 ], b [ 3 ][ 3 ], s [ 3 ][ 3 ], i , j ; printf ( "Enter the values of ...
  • C program for Unit Conversion
    /* Convert Celsius to Fahrenheit */ #include<stdio.h> void main() {     float c,f;     printf("Enter the temperature in Celcius: ...
  • Addition of two numbers on Server sent from Client [TCP] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • Write a Program to Print the Truth Table of Basic Gates using C
  • Write a Program to Add two 5x5 Matrix using C
    #include<stdio.h> void main() {   int a[5][5],b[5][5],c[5][5];   int i,j;   for(i=0;i<5;i++)   {     printf("\nEnter elements ...
  • Using the concept of Inheritance write a C++ Program to calculate the area and perimeter of rectangle
    /* C++ Program to calculate the area and perimeter of rectangles using concept of inheritance. */ #include using namespace std; class Re...
  • Concatenation of two strings sent from Client on the Server - [ TCP ] using C
    /* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #inc...
  • 8085 Programming: Exchange the contents of memory locations
    Exchange the contents of memory locations 2000H and 4000H. Program 1: LDA 2000H : Get the contents of memory location 2000H into accumulator...
  • Calculate Depreciation using C
    #include<conio.h> #include<stdio.h> void main () { float sv , pv , dep ; int yos ; clrscr (); printf ( "Enter the pu...
  • 8085 Programming: 1's COMPLEMENT OF A 16-BIT NUMBER
    The 16bit number is stored in C050,C051 The answer is stored in C052,C053   LXI H,C050   MOV A,M   CMA   STA C052   INX H   MOV ...

Daily Hits

Copyright © Sumit Kar