Showing posts with label C++. Show all posts
Showing posts with label C++. Show all posts

16 September 2014

C Program to find the Largest Prime number less than the given number.

Given a number (as command line argument), find the Largest Prime number less than the given number. For e.g., given 8, the program should return 7.


#include <stdio.h>
int main()
{
    int i,n=2,m,j=0;
    int a[100]={'\0'};
    printf("enter the number in the range[3-500]\n");
    scanf("%d",&m);
    while(n<m)
    {
        for(i=2;i<n;i++)
        {
            if(n%i==0)
            goto t;
        }
        a[j++]=n;
        t : n++;
    }
    printf("largest prime number less than given number is %d\n",a[--j]);
}

31 August 2014

C - IDE

Open source software for c and c++ compilation

Code::Blocks is a free C, C++ and Fortran IDE built to meet the most demanding needs of its users. It is designed to be very extensible and fully configurable.
Finally, an IDE with all the features you need, having a consistent look, feel and operation across platforms.
Built around a plugin framework, Code::Blocks can be extended with plugins. Any kind of functionality can be added by installing/coding a plugin. For instance, compiling and debugging functionality is already provided by plugins!
It can be downloaded from http://www.codeblocks.org/downloads
All you have to do is click on the link , it will redirect you to the downloads website where you can download it . just run the setup file and proceed the installation steps.
Start programming..
#EnjoyLearning 

28 August 2014

Installation for C and C++

How to Install Turbo C++ Version 3.0, Compile and Run C  and C++ Programs


In this article, you will get answers to the following questions:
  • How to Install Turbo C++ Version 3.0?
  • How to create a new C Program using Turbo C++ Version 3.0?
  • How to run a C Program using Turbo C++ Version 3.0?
How to Install Turbo C++ Version 3.0?
Installing Turbo C++ Version 3.0 is very easy and effortless. Follow below mentioned easy steps to install Turbo C:

  • Extract TC.rar folder in your C Drive (“C:\”) 
Congratulation… You are done with installation of Turbo C++ Version 3.0.
How to create a new C Program using Turbo C++ Version 3.0?
  • Open the bin folder (“C:\TC\BIN”)
  • Click on “TC” icon as shown below 
  • TC Icon
  • You will see the following screen:
  • Tourbo C Screen
  • Now, Click on File->New. Please find image below for your reference
  • Create new file
  • Write your C Program. Press F2 (or File->Save) to save your program. On pressing F2, pop window will open (as shown below). You need to specify the name of the program.
    Note:
    For C Program, use .C as extension.
    For C++ Program, use .CPP as extension.
  • Save C Program
How to run a C Program using Turbo C++ Version 3.0?
  • Installing Tourbo C is very simple and effortless. Similarly, compiling and running C Program is very simple and effortless.
    Please make a note that, we can compile and run C Programs without saving it.
  • To compile a C Program you can either press Alt+F9 or Compile->Compile. After you compile your C Program you will see the following screen.
  • Compile C Program
  • To run a C Program you can either press Ctrl+F9 or Run->Run. After you run your C Program you will see the output screen as shown below.
  • Run C Program
These are the steps you need to follow to install, create and a run a C Program successfully.

Getting Started

Hello World Programs in Various languages 

Java :

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello, World");
    }

}



*********************************************************************************************************

C : 

//C hello world example
#include <stdio.h>
 
int main() {

  printf("Hello world\n");
  return 0;
}

****************************************************************************

Python :

Print "Hello World"

***************************************************************************

Php :

<?php
  Print "Hello World! ";
?>

***************************************************************************

C++ :
#include<iostream.h>
int main() {
std::cout << "Hello World!" << std::end1;
return 0;
}

***************************************************************************

Now When you have the programs ready , whats the next step ? -- just Compile and run it . For this you need softwares of that particular programming
languages to be installed in your system. 

To make it convinient for you there is other way you can compile and run without installing any softwares . All you need is an Internet Connection .

If you do have , then goto http://www.compileonline.com/ 
Select the language you want to code on and write and execute your program . your task is done .

But If you want to install the softwares into your system , then go through the next post that is how to install and run programs .



@EnjoyLearning