- C Language -
programing language ka use:-
प्रोग्रामिंग लैंग्वेज का उपयोग सॉफ्टवेयर बनाने में किया जाता है C Language और बेसिक प्रोग्रामिंग लैंग्वेज हैं। C के अलावा अन्य लैंग्वेज भी है C language का एक अपना महत्ब है।
मैं याह प्रति सी लैंग्वेज के बारे में मैं थोड़े से कुछ प्रोग्राम बताऊंगा याहा प्रति कुछ चैप्टरवाइज प्रोग्राम बता रहा हूं।
Programe likhne ka tarika(प्रोग्राम लिखने का तरीका )
#include<Heder file>void main
main()
{
--------------
----------------
----------------
getch();
}
First basic programe of c language-
------------------------------------------------
#include<stdio.h>
#include<conio.h>
void main();
{
clrscr();
printf("HELLO");
getch();
output:
HELLO
HELLO
Secound programme-
Es programe mai '\n' and '\t' ka use bta rha hu enka use es prakar hai.
\n = New Line
\t = Horizontal Tab (matlab space)
#include<stdio.h>
#include<conio.h>
void main();
{
clrscr();
printf("HELLO\nGOOD");
printf("HELLO\tGOOD");
getch();
}
output:
HELLO
GOOD
HELLO GOOD
में यहाँ पर कुछ प्रोग्राम के बेसिक से प्रोग्राम के बारे में बताने जा रहा हू |
#include<conio.h>
void main();
{
clrscr();
printf("HELLO\nGOOD");
printf("HELLO\tGOOD");
getch();
}
output:
HELLO
GOOD
HELLO GOOD
में यहाँ पर कुछ प्रोग्राम के बेसिक से प्रोग्राम के बारे में बताने जा रहा हू |
Programe to find area (Circle, Rectangle, Trangle, Square)
1. Area of Circle
- #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float r,area;
printf("enter radius:");
scanf("%d",&r);
area=3.14*r*r;
printf("area of circle=%d",area);
getch();
}
Output:
enter radius:5
area of circle=78.5
#include<conio.h>
void main()
{
clrscr();
float r,area;
printf("enter radius:");
scanf("%d",&r);
area=3.14*r*r;
printf("area of circle=%d",area);
getch();
}
Output:
enter radius:5
area of circle=78.5
2.Area of Rectangle
#include<stdio.h>
#include<conio.h>void main(){clrscr();int l,b,area;printf("enter lenght & breath:");scanf("%d%d",&l,&b);area=l*b;printf("area of ractangle=%d",area);getch();}
Output:
enter lenght & breath:4
5
area of rectangle=20
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int l,b,area;
printf("enter lenght & breath:");
scanf("%d%d",&l,&b);
area=l*b;
printf("area of ractangle=%d",area);
getch();
}
Output:
enter lenght & breath:4
5
area of rectangle=20
Output:
enter lenght & breath:4
5
area of rectangle=20
3. Area of trangle
- #include<stdio.h>
#include<conio.h>void main(){clrscr();
int h,b,area;
printf("Enter hight and base:");scanf("%d%d",&l,&b);
area=0.5*h*b;
printf("Area of trangle=%d",area);
getch();
}
Output:
Entrer hight and base:3
4
Area of trangle=6
#include<stdio.h>
area=0.5*h*b;
printf("Area of trangle=%d",area);
getch();
}
Output:
Entrer hight and base:3
4
Area of trangle=6
#include<conio.h>
void main()
{
clrscr();
int h,b,area;
printf("Enter hight and base:");
scanf("%d%d",&l,&b);int h,b,area;
printf("Enter hight and base:");
area=0.5*h*b;
printf("Area of trangle=%d",area);
getch();
}
Output:
Entrer hight and base:3
4
Area of trangle=6
4.Area of Square
- #include<stdio.h>
#include<conio.h>
void main()
{
int area,s;
clrscr();
printf("enter one side:");
scanf("%d%d",&s);
area=s*s;
printf("Area of square=%d",area);
getch();
}
Output:
enter one side:5
Area of square=25
#include<stdio.h>
#include<conio.h>
void main()
{
int area,s;
clrscr();
printf("enter one side:");
scanf("%d%d",&s);
area=s*s;
printf("Area of square=%d",area);
getch();
}
Output:
enter one side:5
Area of square=25
#include<conio.h>
void main()
{
int area,s;
clrscr();
printf("enter one side:");
scanf("%d%d",&s);
area=s*s;
printf("Area of square=%d",area);
getch();
}
Output:
enter one side:5
Area of square=25
1. Area of Circle
- #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float r,area;
printf("enter radius:");
scanf("%d",&r);
area=3.14*r*r;
printf("area of circle=%d",area);
getch();
}
Output:
enter radius:5
area of circle=78.5
#include<conio.h>
void main()
{
clrscr();
float r,area;
printf("enter radius:");
scanf("%d",&r);
area=3.14*r*r;
printf("area of circle=%d",area);
getch();
}
Output:
enter radius:5
area of circle=78.5
2.Area of Rectangle
#include<stdio.h>
#include<conio.h>void main(){clrscr();int l,b,area;printf("enter lenght & breath:");scanf("%d%d",&l,&b);area=l*b;printf("area of ractangle=%d",area);getch();}
Output:
enter lenght & breath:4
5
area of rectangle=20
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int l,b,area;
printf("enter lenght & breath:");
scanf("%d%d",&l,&b);
area=l*b;
printf("area of ractangle=%d",area);
getch();
}
Output:
enter lenght & breath:4
5
area of rectangle=20
Output:
enter lenght & breath:4
5
area of rectangle=20
3. Area of trangle
- #include<stdio.h>
#include<conio.h>void main(){clrscr();
int h,b,area;
printf("Enter hight and base:");scanf("%d%d",&l,&b);
area=0.5*h*b;
printf("Area of trangle=%d",area);
getch();
}
Output:
Entrer hight and base:3
4
Area of trangle=6
#include<stdio.h>
area=0.5*h*b;
printf("Area of trangle=%d",area);
getch();
}
Output:
Entrer hight and base:3
4
Area of trangle=6
#include<conio.h>
void main()
{
clrscr();
int h,b,area;
printf("Enter hight and base:");
scanf("%d%d",&l,&b);int h,b,area;
printf("Enter hight and base:");
area=0.5*h*b;
printf("Area of trangle=%d",area);
getch();
}
Output:
Entrer hight and base:3
4
Area of trangle=6
4.Area of Square
- #include<stdio.h>
#include<conio.h>
void main()
{
int area,s;
clrscr();
printf("enter one side:");
scanf("%d%d",&s);
area=s*s;
printf("Area of square=%d",area);
getch();
}
Output:
enter one side:5
Area of square=25
#include<stdio.h>
#include<conio.h>
void main()
{
int area,s;
clrscr();
printf("enter one side:");
scanf("%d%d",&s);
area=s*s;
printf("Area of square=%d",area);
getch();
}
Output:
enter one side:5
Area of square=25
#include<conio.h>
void main()
{
int area,s;
clrscr();
printf("enter one side:");
scanf("%d%d",&s);
area=s*s;
printf("Area of square=%d",area);
getch();
}
Output:
enter one side:5
Area of square=25
Programe to find operators
Operator
Operator is a three types.- Unary
- Binary
- Turnary
1.Unary-
- Increment / Decrement operator
#include<stdio.h>
#include<conio.h>
void main()
{
int x;
printf("Enter a no:");
scanf("%d",&x);
printf("prefix----------\n");
printf("x=%d\n",x);
printf("++x=%d\n",(++x));
printf("x=%d\n",x);
printf("--x=%d\n",(--x));
printf("Postfix-----------\n");
printf("x++=%d\n",(x++));
printf("x=%d\n",x);
printf("x--=%d\n",(x--));
printf("x=%d\n,x);
getch();
}
output:
enter a no:5
prefix--------------
x=5
++x=6
x=6
--x=5
x=5
postfix--------------
x++=5
x=6
x--=6
x=5
2.Binary operator
- Arithmatic operator ( + , - , * , / , % )
#include<stdio.h>
#include<conio.h>
void main()
{
int x1,x2;
printf("Enter two value:");
scanf("%d%d",&x1,&x2);
printf("Addition=%d",(x1+x2));
printf("Subtract=%d",(x1-x2));
printf("Multiply=%d",(x1*x2));
printf("Divide=%d",(x1/x2));
printf("Remainder=%d",(x1%x2));
getch();
}
Output:
Enter two value:5
3
Addition=8
Subtract=2
Multiply=15
Divide=1
Remainder=2
#include<conio.h>
void main()
{
int x1,x2;
printf("Enter two value:");
scanf("%d%d",&x1,&x2);
printf("Addition=%d",(x1+x2));
printf("Subtract=%d",(x1-x2));
printf("Multiply=%d",(x1*x2));
printf("Divide=%d",(x1/x2));
printf("Remainder=%d",(x1%x2));
getch();
}
Output:
Enter two value:5
3
Addition=8
Subtract=2
Multiply=15
Divide=1
Remainder=2
- Relational operator ( < , > , <= , >= , == , != )
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two value:");
scanf("%d%d",&a,&b);
if(a>b)
printf("%d is greater than %d\n",a,b);
if(a<b)
printf("%d is lass than &b\n",a,b);
if(a>=b)
printf("%d is greater then equal %d\n",a,b);
if(a<=b)
printf("%d is lass than equal &d\n",a,b);
if(a==b)
printf("%d is equal to %d\n",a,b);
if(a!=b)
printf("%d is not equal to %d\n",a,b);
getch();
}
Output:
Enter two value:5
3
5 is greater than 3
5 is lass than 3
5 is not equal to 3
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two value:");
scanf("%d%d",&a,&b);
if(a>b)
printf("%d is greater than %d\n",a,b);
if(a<b)
printf("%d is lass than &b\n",a,b);
if(a>=b)
printf("%d is greater then equal %d\n",a,b);
if(a<=b)
printf("%d is lass than equal &d\n",a,b);
if(a==b)
printf("%d is equal to %d\n",a,b);
if(a!=b)
printf("%d is not equal to %d\n",a,b);
getch();
}
Output:
Enter two value:5
3
5 is greater than 3
5 is lass than 3
5 is not equal to 3
- Assignment operator ( = , += , -= ,*= , /= , %= )
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
a=5;
b=10;
printf("a=%d\tb=%d\n",a,b)
printf("a+=a -> %d\n",(a+=a));
printf("b-=6 -> %d\n",(b-=6));
printf("a*=10 -> %d\n",(a*=10));
printf("a/=2 -> %d\n",(a/=2));
printf("b%=2 -> %d\n",(b%=2));
getch();
}
Output:
a=5 b=10
a+=a -> 10
b-=6 -> 4
a*=10 -> 100
a/=2 -> 50
b%=2 -> 0
- Logical operator (&& , || , ! )
- Logical operator (&& , || , ! )
compare between condition
a) AND &&
b) OR ||
c) NOT !
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter two value:");
scanf("%d%d",&a,&b);
if(a>=5&&b!=6)
printf("True1\n");
if(a!=6&&b>=15)
printf("True2\n");
if(a>=5&&b!=6)
printf("True3\n");
if(a!=6||b>=15)
printf("True4\n");
if(!(a>=15))
printf("True5\n");
if(!(a<5))
printf(True6\n");
getch();
}
Output:
Enter two value:6
8
True1
True3
True5
True6
a) AND &&
b) OR ||
c) NOT !
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter two value:");
scanf("%d%d",&a,&b);
if(a>=5&&b!=6)
printf("True1\n");
if(a!=6&&b>=15)
printf("True2\n");
if(a>=5&&b!=6)
printf("True3\n");
if(a!=6||b>=15)
printf("True4\n");
if(!(a>=15))
printf("True5\n");
if(!(a<5))
printf(True6\n");
getch();
}
Output:
Enter two value:6
8
True1
True3
True5
True6
3.Turnary Operater ( ? and : operater)
- 1st programe
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two no:");
scanf("%d%d",&a,&b);
a>b?printf("%d is greater ",a):printf("%d is greater ",b);
getch();
}
Output:
Enter two no:5
6
6 is greater
#include<stdio.h>
#include<conio.h>
void main();
{
int a,b,max;
clrscr();
printf("Enter two number");
scanf("%d%d",&a,&b);
max=a>b?a:b;
printf("Maximum=%d",max);
getch();
}
Output:
Enter two number:8
4
Maximum=8
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter two no:");
scanf("%d%d",&a,&b);
a>b?printf("%d is greater ",a):printf("%d is greater ",b);
getch();
}
Output:
Enter two no:5
6
6 is greater
- 2nd programe
#include<stdio.h>#include<conio.h>
void main();
{
int a,b,max;
clrscr();
printf("Enter two number");
scanf("%d%d",&a,&b);
max=a>b?a:b;
printf("Maximum=%d",max);
getch();
}
Output:
Enter two number:8
4
Maximum=8
kuch important programe
ADD TWO NUMBER
---------------------------------------
#include<conio.h>
void main();
{
clrscr();
int a,b,c;
printf("enter two no:");
scanf("%d%d",&a,&b);
c=a+b;
printf("add="%d);
getch();
}
Output:
enter two no:6
7
add=13
Subtract two number-------------------------------
#include<stdio.h>#include<conio.h>
void main();
{
clrscr();
int a,b,c;
printf("enter two no:");
scanf("%d%d",&a,&b);
c=a-b;
printf("Subtract="%d);
getch();
}
Output:
enter two no:8
4
subtract=4
--------------------
#include<stdio.h>#include<conio.h>
void main()
{
int P,R,T,SI;
clrscr();
printf("Enter principle, rate of intrest and number of year:");
scanf("%d%d%d",&P,&R,&T);
SI=(P*R*T)/100;
printf("Simple intrest=%d",SI);
getch();
}
Output:
Enter principle, rate of intrest and number of year:200
100
2
Simple intreast=400
Compound Intrest
--------------------------
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int P,R,T,CI;
printf("enter principal,rate of intrest and number of year:");
scanf("%d%d%d",&P,&R,&T);
CI=P*pow((1+(R/100)),T);
printf("Compound Intrest=%d",CI);
getch();
}
Output:
enter principal,rate of intrest and number of year:200
100
2
Compound Intrest=800
#include<conio.h>
#include<math.h>
void main()
{
int P,R,T,CI;
printf("enter principal,rate of intrest and number of year:");
scanf("%d%d%d",&P,&R,&T);
CI=P*pow((1+(R/100)),T);
printf("Compound Intrest=%d",CI);
getch();
}
Output:
enter principal,rate of intrest and number of year:200
100
2
Compound Intrest=800
No comments: