## Sunday, June 25, 2017

### Fahrenheit to Celsius using C++

Write C++ program to read temperature in Fahrenheit and print it in Celsius.

#include<iostream>
using namespace std;

int main()
{
float f,c;
cout << "Enter temperature in Fahrenheit(f)=";
cin >> f;

c = 5 * ( f - 32 ) / 9;

cout<<"Temperature in Celsius = " << c;

return 0;
}

Output of program

Enter temperature in Fahrenheit(f)=100
Temperature in Celsius = 37.7778

### Simple Interest using C++ Program.

#include<iostream>
using namespace std;

int main()
{
float P,R,N,I;

cout<<"Enter Principle Amount: ";
cin>>P;

cout<<"Enter Rate of Interest: ";
cin>>R;

cout<<"Enter No. of Years: ";
cin>>N;

I=(P*R*N)/100;

cout<<"Simple interest is : "<< I;

return 0;
}

Output of Program

Enter Principle Amount: 1000
Enter Rate of Interest: 12
Enter No. of Years: 2
Simple interest is : 240

## Friday, June 23, 2017

### Using char variable in C++ programs.

#include<iostream>
using namespace std;

int main()
{
char name[20];

cin>>name;

cout<<"Your Name is : "<< name;
return 0;
}

Output of program

Note: This program will be able to read only one word as your name.

## Thursday, June 22, 2017

### Using int in C++ Program

Example of using integer variables in C++ programs.

#include<iostream>
using namespace std;

int main()
{
int rollno;
cout<<"What is your Roll Number? ";
cin>>rollno;
return 0;
}

Output of Program

What is your Roll Number? 101

### Hello World in C++

Let’s begin with a simple C++ program to display "Hello World" on the screen.

Example: Hello World Program in C++

 #include using namespace std; int main()  {     cout << "Hello World";     return 0; }

Output of program

Hello World

Description of Program
• C++ program starts from the main() function.
• cout is the standard output stream to print "Hello, World!" on monitor.
• return 0; indicates program ends and returns 0 to calling program.
* * * * *

## Sunday, June 11, 2017

### Difference between C and Python

C and Python are general purpose computer programming language. Python is generally preferred for server side scripting. Some of the key difference between C and Python are given below:

Table: Difference between C and Python

 C Language Python Language Designed by Dennis Richie Product from Python Software Foundation C programs are faster but coding is complex and long Coding is easier and short in Python C requires type declaration Python does not require type declaration C supports in line assignment Python does not support in line assignment