Wednesday 25 November 2015

Program to add,subtract,multiply and divide.-
‪#‎include‬ <stdio.h>
int main()
{
int first, second, add, subtract, multiply;
float divide;
printf("Enter two integers\n");
scanf("%d%d", &first, &second);
add = first + second;
subtract = first - second;
multiply = first * second;
divide = first / (float)second; //typecasting
printf("Sum = %d\n",add);
printf("Difference = %d\n",subtract);
printf("Multiplication = %d\n",multiply);
printf("Division = %.2f\n",divide);
return 0;
}

Analysis of second program-

Tuesday 24 November 2015

The most important and the first program that you write in any language is the "hello world" program. It teaches us about the basic syntax and format of a particular language and helps us understanding it better. So for beginners have a look and enjoy.
‪#‎include‬ <stdio.h>
int main()
{
/* my first program in C */
printf("Hello, World! \n");
This tutorial gives you easy-to-follow instructions, with screenshots, for setting up a compiler, a tool that will let you turn the code that you write into programs, and Code::Blocks, a free development environment for C and C++. This tutorial explains how to install Code::Blocks on Windows; if you're on OS X, go here to get set up using Apple XCode.

Step 1: Download Code::Blocks

  • Go to this website: http://www.codeblocks.org/downloads
  • Follow the link to "Download the binary release" (direct link)
  • Look for the file that includes mingw in the name. (The name as of this writing was codeblocks-10.05mingw-setup.exe; the 10.05 may be different).

Step 2: Install Code::Blocks

  • Double click the installer.
  • Hit next several times. Other setup tutorials will assume you have installed in C:\Program Files\CodeBlocks (the default install location), but you may install elsewhere if you like
  • Do a Full Installation
  • Launch Code::Blocks

Step 3: Running in Code::Blocks

You will be prompted with a Compilers auto-detection window: 

Compiler Auto-Detection Window 

When you get the compiler auto-detection window, just hit OK. Code::Blocks may ask if you want to associate it as the default viewer for C/C++ files--I'd suggest you do. Click on the File menu, and under "New", select "Project..." 

The following window will come up: 

New Project Window 

Click on "Console Application" and hit the "Go" button. 

Click next until you get to the Language Selection Dialog: 

Language selection dialog 

You'll be asked to choose whether you want to use C or C++. If you're not sure, use C++. Otherwise, choose based on the language you are learning. (You can find tutorials here on both C and C++.) 

After clicking "Next", Code::Blocks will then prompt you with where you'd like to save the console application: 

Project Name and Location 

I'd recommend you put it in its own folder, as it may create several files (this is especially true if you create other types of projects). You will need to give your project a name, anything will be fine. 

Clicking "Next" again will prompt you to set up your compiler: 

Compiler Setup 

You don't need to do anything here. Just accept the defaults by hitting "Finish". 

You can now open the main.cpp file on the left: 

Main Editor View (You may need to expand the contents of the "Sources" folder if you don't see main.cpp.) 

At this point, you will have your main.cpp file, which you can modify if you like. For now, it just says "Hello World!", so we can run it as is. Hit F9, which will first compile it and then run it. 

Running Program 

You now have a running program! You can simply edit main.cpp and then hit F9 to compile it and run it again.