FreePrograms


C language is a middle level language. It is a structured language. C language is a case sensitive language. All syntax written in c language is in lower case. C is the basis for C++.
  CONTACT US   ABOUT US   PRIVACY  DISCLAIMER

FREE C PROGRAMS 

What is C C vs C++ vs Java Program Structure Data Types in C Basic Rules of C & C++
Functions in C If, Else Conditions Loops in C Switch Case Arrays
Pointers Structures in C Strings in C Command Line Arguments Type Casting
Linked Lists Recursion Binary Trees Inheritance Multiple Inheritance
Templates File I/O Object Oriented Programming Data Structures in C C interview Questions

A Basic C program has Header Files, Functions, Variables, Statements & Expressions, Comments or Meanings.

Example:

#include <stdio.h>
 
int main(void)
{
    printf("hello, world\n");
    return 0;
}

In above program we have header file stdio.h. We have function main.

We can also declare some variables of some data type for mathematical calculations. For example see this program where we check whether a number is prime or non prime, we are using integer type variables i, flag and a as defined below.

//Check whether a number is prime or not

#include<conio.h>//header file
#include<stdio.h>//header file
void main() //starting of the main() function
{
int i,flag=0,a;//declaration of the variables
clrscr();
printf("Test whether a given no. is prime or not");
printf("\n\n\n\t\t------------INPUT-------------");
printf("\n\nenter a no. to be checked prime or not");//taking input from the user
scanf("%d",&a);
for(i=2;i<a;i++)
{
if(a%i==0)
{
flag=1;
break;
}
}
printf("\n\n\n\t\t------------OUTPUT------------");
if(flag==0)
printf("\n\nit is a prime no."); //printing output
else
printf("\n\nit is not a prime no."); //printing output
getch();
}

COPYRIGHT 2009 ALL RIGHTS RESERVED FREECPROGRAMS.COM