Programming Practice
Aj serf Programming ke practice ho ge u rap sab es ko implement b kary me kuch program banta hun and ur dewtail se samjoo ga k ye kesy work kary ga
Write A program which Add two integer Number ?
#include<iostream.h>
I#inlude<conio.h>
void main()
{
clrscr();
int a,b,sum; // a use for first value and b use for second value and sum use for result
cout<<”enter first value”<<endl; //endl use for new line
cin>>a;
cout<<”enter sec value”<<endl; //” use for string
cin>>b;
sum=a+b;
cout<<”the sum of two integer is =”<<sum;
getch();
}
I#inlude<conio.h>
void main()
{
clrscr();
int a,b,sum; // a use for first value and b use for second value and sum use for result
cout<<”enter first value”<<endl; //endl use for new line
cin>>a;
cout<<”enter sec value”<<endl; //” use for string
cin>>b;
sum=a+b;
cout<<”the sum of two integer is =”<<sum;
getch();
}
Endl ham newline par any k lay use karty hai and jo “” lagty hai ye string k agr ye na lagoo to error aye ga
Output::
agr ap first value 3 ly and sec 2 to result 5 aye ga
es traha hp ga
Enter first value 3
enter sec value 3
the sum of two interger is = 5
agr ap first value 3 ly and sec 2 to result 5 aye ga
es traha hp ga
Enter first value 3
enter sec value 3
the sum of two interger is = 5
Write a program to check area and perimeter?
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int L,W,A,P;
cout<<”length”<<endl;
cin>>L;
cout<<”width”<<endl;
cin>>W;
P=2*(L+W)
cout<<P<endl;
A=L*W;
cout<<A<<endl;
getch();
}
#include<conio.h>
void main()
{
clrscr();
int L,W,A,P;
cout<<”length”<<endl;
cin>>L;
cout<<”width”<<endl;
cin>>W;
P=2*(L+W)
cout<<P<endl;
A=L*W;
cout<<A<<endl;
getch();
}
Es program me ham perimeter and area maloum karain gy to area ya perimeter ko maloum karny k lay hamy length and width ke zarort ho to length and width user se lany gy per es par perimeter ka formula apply ho ga (2*(l+w)) ka jo value user ne l and w ko de ho ge wo 2 se multiplay ho ge and new walue perimeter me add ho k show gee s k bad area k ly use ke vale multiplay ho k area ke new value show ho jai ge
(3)
Write a program to get the value from user calculate the sum and product of the number and then print
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,b,s,p;
cout<<”enter first value”<<endl;
cin>>n;
cout<<”enter sec value”<<endl;
cin>>b;
s=n+b; // s use for sum
p=a*b; // p use for product
cout<<”the sun of numbers is =”<<s<<endl;
cout<<”the product of numbers is =”<<p<<endl;
getch();
}
es meham user se input lain gy 2 value wo pehly + ho k sum me add ho jai ge then * ho k p me add ho jai ge ur per pehly suym ka result show ga then product ka .. out put es traha ka ho ga
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,b,s,p;
cout<<”enter first value”<<endl;
cin>>n;
cout<<”enter sec value”<<endl;
cin>>b;
s=n+b; // s use for sum
p=a*b; // p use for product
cout<<”the sun of numbers is =”<<s<<endl;
cout<<”the product of numbers is =”<<p<<endl;
getch();
}
es meham user se input lain gy 2 value wo pehly + ho k sum me add ho jai ge then * ho k p me add ho jai ge ur per pehly suym ka result show ga then product ka .. out put es traha ka ho ga
enter first value
2
enter sec value
7
the sum of numbers is = 9
the product of numbers =14
Ok aj k lay ye kafi ta ap log khud se b koi program bana lay ur diky k kesy run ho ga ok thanks 2
enter sec value
7
the sum of numbers is = 9
the product of numbers =14
Reg:: MT ALI OKZ
No comments:
Post a Comment