On the demand of the students I am uploading some basic programs.Hope this will benefit you all.
// WRITE A PROGRAM TO ENTER TEMP IN FAHRENHIET AND CONVER IT IN CELCIUS
#include<iostream.h>
#include<conio.h>
void main()
{
float f,c;
cout<<"enter temp in fahrenheit"<<endl;
cin>>f;
c=5*(f-32)/9;
cout<<"The temp in celcius is:"<<c<<endl;
getch();
}
// WRITE A PROGRAM TO ENTER TEMP IN FAHRENHIET AND CONVER IT IN CELCIUS
#include<iostream.h>
#include<conio.h>
void main()
{
float f,c;
cout<<"enter temp in fahrenheit"<<endl;
cin>>f;
c=5*(f-32)/9;
cout<<"The temp in celcius is:"<<c<<endl;
getch();
}
// WRITE A PROGRAM TO ENTER TWO NUMBERS AND SWAP THEM
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,z;
cout<<"Enter two numbers"<<endl;
cin>>x>>y;
z=x;
x=y;
y=z ;
cout<<"The numbers after swapping:"<<endl;
cout<<"x is :="<<x<<endl<<"y is :="<<y<<endl;
getch();
}
// WRITE A PROGRAM TO ENTER TWO NUMBERS AND SWAP THEM WITHOUT USING THIRD VARIABLE
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,z;
cout<<"Enter two numbers"<<endl;
cin>>x>>y;
x=x+y;
x=x-y;
y=x-y;
cout<<"The numbers after swapping:"<<endl;
cout<<"x is :="<<x<<endl<<"y is :="<<y<<endl;
getch();
}
//enter a four digit number and find the sum of first and last
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num,first,last,sum;
cout<<"enter a four digit number"<<endl;
cin>>num;
last=num%10;
first=num/1000;
sum=first+last;
cout<<"the sum of first and last digit is ="<<sum<<endl;
getch();
}
thanx sir .thank u so much .sir please wapas aa jao yaha pe sir kuch thik se padha nahi pa rahe hain
ReplyDelete