Hello friends welcome again to my site. here we are going to learn 'c' programming and also analyse the 'c' language programs.
so without taking, time we are going to see
all the programs.
first of all, we
have to know about the c programming so some information about c is given
below.and also describe features of c programming with introduction..
⧭ what is 'c' language.
⧪ 'c' is a programming language
which is developed by “Dennis M. Ritchi”.
c language is invented in 1972 at AT&T
Bell laboratory. It is a general purpose programming language.
⧪ History of 'c' :-
⧪ History of 'c' :-
In 1967 a programming language BCPL(basic combined programming language) developed by “Martin Richards” after this language a new programming language named “B” is developed as the easier language as compare to BCPL. This programming language was developed by “Ken Thompson” in 1970 at AT&T Bell laboratory. After b programming language c programming language was invented by dennis Ritchie for general purpose.
⧪here some features of c language given below:
1- c language is a structured programming
language. here i want to tell something about structured programming this type of
programming in which all the statements are in a sequence.
2- c language is a sensitive
programming language.
3- c language is a mid level
programming language here mid level programming language means that c programming contains some
features of low level language and all other features of high level language.
so it is famous as mid level language.
4- c programming language is syntax based programming
language because it uses many types of
syntax.
5- it uses pointers for storage management and location.
6- c programming is a compiler based programming
language.everyone knows that every high level language are completely based on
compiler.
Did
you know that a compiler is work on zero & not zero condition here zero
means false and non zero means true.
Some advantages of c programming language are given below:-
(a)- c programming used in embedded programming language.
(b)-c programming supports various operators and operands.
(c)- c programming is machine dependent programming
language.
After knowing the introduction of c programming we are going
to create some programs of c programming.
-: PROGRAMS IN ‘C’ :-
1-
|
Program to print something
|
2-
|
Program to find out area of circle
|
3-
|
Program to addition of variables of integer
|
4-
|
Program to find out simple interest
|
5-
|
Program to divide of variables of integer &
float
|
6-
|
Program for multiply of two numbers
|
7-
|
Program of subtraction of two numbers.
|
8-
|
Program to find square of a number.
|
9-
|
Program to find cube of a number.
|
10-
|
Program to find out simple interest by using “scanf”
function.
|
11-
|
Program to find percentage of exam, value given by
user.
|
12-
|
Program to find average of numbers.
|
13-
|
Program to find out a number is odd or even.
|
14-
|
Program to find out a number is positive or
negative.
|
15-
|
Program to find division of students in five
subjects by using if-else statement.
|
16-
|
Program to find division to percentage by using nesting
if-else statements.
|
17
|
Program to find greater number by using conditional
operator.
|
18-
|
Program to find smaller value by using conditional
operator.
|
19-
|
Program to print 1 to 10 numbers by using do-while
loop.
|
20-
|
Program to determine whether a person has made
profit or incurred loss &
|
Also determine the unit of profit & loss.
|
|
21-
|
Program to print table of 2.
|
22-
|
Program to print table of number given by user.
|
23-
|
Program to change temperature from Celsius to
Fahrenheit.
|
24-
|
Program to find a alphabet is vowel or consonant.
|
25-
|
Program to find largest values among three values.
|
26-
|
Program to print any name 5 times by using ‘for’
loop.
|
27-
|
Program to find out factorial of a number.
|
28-
|
Program to find factors of a positive number.
|
29-
|
Program to find smallest values among three values.
|
30-
|
Program to swap two numbers without any function.
|
31-
|
Program to find power of a number using ‘for’ loop.
|
1-Program to print something:-
#include<stdio.h>
#include<conio.h>
void
main( )
{
print(“priyanshu”);
getch(
);
}
output:-

2-program to find out area
of circle:-
#include<stdio.h>
#include<conio.h>
void
main( )
{
clrscr(
);
float
r=3
float
pi=3.14;
float
area;
area=pi*r*r;
printf(“%f”,area);
getch(
);
}
output:-
3-program to addition of variables of integer:-
#include<stdio.h>
#include<conio.h>
void main( );
{
clrscr( );
int a=2;
int c;
c=a+b;
printf(“%d”,c);
getch( );
}
output:-

4-program to find out simple interest:-
#include<stdio.h>
#include<conio.h>
void main( );
{
clrscr( );
int p=2000;
float r=2.6;
int n=6;
float si;
si=p*r*n/100;
printf(“%f”,si);
getch( );
}
output:-

5-program to dividation of variables of integer & float:-
#include<stdio.h>
#include<conio.h>
void main( );
{
clrscr( );
int a=6;
float b=1.5;
float c;
c=a/b;
printf(“%f”,c);
getch( );
}
output:-

6-program for multiply of two number:-
#include<stdio.h>
#include<conio.h>
void main( );
{
clrscr( );
int a=6;
int b=10;
float c;
c=a*b;
printf(“%d”,c);
getch( );
}
output:-

7-program of subtraction of two numbers:-
#include<stdio.h>
#include<conio.h>
void main( );
{
clrscr( );
int a=6;
int b=10;
int c;
c=b-a;
printf(“%d”,c);
getch( );
}
output:-

8-Program to find square of a number:-
#include<stdio.h>
#include<conio.h>
int main( );
{
clrscr( );
int a,b;
printf(“enter any number to find its
square”);
scanf(“%d”,&a);
b=a*a;
printf(“square of %d is %d”,a,b);
getch( );
}
output:-

9-program to find out cube of a number:-
#include<stdio.h>
#include<conio.h>
int main( );
{
clrscr( );
int a,b;
printf(“enter any number to find its cube”);
scanf(“%d”,&a);
b=a*a*a;
printf(“cube of %d is %d”,a,b);
getch( );
}
Output:-

10- program to calculate simple interest by using ‘scanf’
function:-
#include<stdio.h>
#include<conio.h>
int main( );
{
clrscr( );
int principle,rate,time,si;
printf(“enter principle ”);
scanf(“%d”,&principle);
printf(“enter rate ”);
scanf(“%d”,&rate);
printf(“enter time ”);
scanf(“%d”,&time);
si=principle*rate*time/100;
printf(“simple interest=%d”);
getch( );
}
Output:-

11-Progrm to find out percentage of exam, value given by user:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( ):
float m;
[here m=marks
float t;
t=total,
float p; p=percentage
float pt; pt=paper total]
printf(“enter your marks”);
scanf(“%f”,&m);
printf(“enter your exam total”);
scanf(“%f”,&t);
printf(“enter your paper total”);
scanf(“%f”,pt);
p=m*pt/t;
printf(“your percentage is=%f”,p);
getch( );
}
output:-

12-Progam to find average of 5 numbers:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( ):
float a,b,c,d,e;
float avg;
printf(“enter the numbers=”);
scanf(“%f%f%f%f%f”,avg);
avg=(a+b+c+d+e)/5;
printf(“average=%f”,avg);
getch( );
}
output:-

13-program to find out a number is even or odd:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( ):
int n;
printf(“enter any number”);
scanf(“%d”,&n);
if(n%2==0)
{
printf(“number is even”);
}
else
{
printf(“number is odd”);
}
getch( );
}
output:-

14- program to find out a number is positive or negative:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( ):
float n;
printf(“enter any number”);
scanf(“%f”,&n);
if(n>0)
{
printf(“number is positive);
}
else
{
printf(“number is negative);
}
getch( );
}
output:-

15- Program to find division of students in 5 subjects by using
if-else statement:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int m1,m2,m3,m4,m5, perc;
printf(“enter the numbers of 5 subjects”);
scanf(“%d%d%d%d%d”,&m1,&m2,&m3,&m4,&m5);
if(perc >=60)
printf(“you have got first division”);
else
{
if(perc >=50)
printf(“you have got second division);
if(perc >=40)
printf(“you have got third division”);
else
printf(“you are fail”);
}
getch( );
}
output:-

16: Program to find out division to percentage by using nesting
if-else statement :-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int p;
printf(“enter your percentage”);
scanf(“%f”,&p);
if(p>=60);
printf(“you have got 1st
division”);
else
{
if(p>=50);
{
printf(“you have got 2nd
division”);
}
if (p>=35)
{
printf(“you have got third division”);
}
else
printf(“you are fail”);
}
getch( );
}
output:-

17: program to find greater number by using conditional operator:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int x,y;
printf(“enter a value of x=”);
scanf(“%d”,&x);
printf(“enter a value of y=”);
scanf(“%d”,&y);
((x>y)?printf(“greater value
is=%d”,x):printf(“greater value is=%d”,y));
getch( );
}
output:-

18: program to find small value by using conditional operator:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int x,y;
printf(“enter a value of x=”);
scanf(“%d”,&x);
printf(“enter a value of y=”);
scanf(“%d”,&y);
((x<y)?printf(“small value
is=%d”,x):printf(“small value is=%d”,y));
getch( );
}
output:-

19: program to print 1 to 10 numbers by using do-while loop:-
#include<stdio.h>
#include<conio.h>
void main( );
{
clrscr( );
int i=1;
do
{
printf(“\t %d”,i),i++;
}
while (i<=10);
getch( );
}
output:-

20: program to determine whether a person has made profit or
incurred loss & also determine units of profit & loss:-
#include<stdio.h>
#include<conio.h>
void main( );
{
clrscr( );
int sp,cp,profit,loss;
printf(“enter the sail price”);
scanf(“%d”,&sp);
printf(“enter the cost price”);
scanf(“%d”,&cp);
if(sp>cp)
{
profit=cp-sp;
printf(“you’re in the profit with %d
unit”,profit);
}
else
{
loss=sp-cp;
printf(“you’re in the loss with %d unit”);
}
getch( )
}
output:-

21: program to print table of 2:-
#include<stdio.h>
#include<conio.h>
void main( );
{
clrscr( );
int n=2,r;
printf(“the table of 2:-“);
for(r=1;r<=10;r++)
{
printf(“\n %d*%d=%d”,n,r,n*r);
}
getch( );
}
output:-

22:program to print table of number, given by user:-
#include<stdio.h>
#include<conio.h>
void main( );
{
clrscr( );
int n,r;
printf(“enter the number”);
scanf(“%d”,&n);
printf(“the table of %d:-”,n);
for(r=1;r<=10;r++)
{
printf(“\n %d*%d=%d”,n , r , n*r);
}
getch( );
}
output:-

23: program to change temperature from celsius to fahrenheit :-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
float c,f;
printf(“enter the temperature in celsius”);
scanf(“%f”,&c);
f=c*9/5+32;
printf(“fahrenhiet=%f”,f);
getch( );
}
output:-

24: program to find a alphabet is vowel or consonent:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
char c;
printf(“enter the alphabet”);
scanf(“%c”,&c);
If(c==’A’ || c==’E’ || c==’I’ || c==’O’ ||
c==’U’)
{
printf(“%c is vowel”,c);
}
else
printf(“%c is consonent”,c);
getch( );
}
output:-

25: program to find largest value among three values:-
##include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int x,y,z;
printf(“enter first value:”);
scanf(“%d”,&x,);
printf(“enter second value:”);
scanf(“%d”,&y,);
printf(“enter third value:”);
scanf(“%d”,&z,);
if(x>y && x>z)
{
printf(“the greatest value is %d”,x);
}
else if(y>z)
{
printf(“the greatest value is %d”,y);
}
else
{
printf(“the greatest value is %d”,z);
}
getch( );
}
output:-

26: program to print any name 5 times by using for loop:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int i;
for(i=1;i<=5;i++)
{
printf(“\npriyanshu”,i);
}
getch( );
}
output:-

27: program to find out factorial of a number:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int i,n,fact;
printf(“enter any number”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
fact=fact*i;
}
printf(“\n%d =%d”,fact);
getch( );
}
output:-

28: program to find factors of a positive number:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int num,i;
printf(“enter a positive number:”);
scanf(“%d”,&num);
printf(“factors of %d is:”num);
for(i==1;i<=num;++i)
{
if(num%i==0)
printf(“%d,”,i);
}
getch( );
}
output:-

29: program to find smallest value among three values:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int x,y,z;
printf(“enter first value:”);
scanf(“%d”,&x,);
printf(“enter second value:”);
scanf(“%d”,&y,);
printf(“enter third value:”);
scanf(“%d”,&z,);
if(x<y && x<z)
{
printf(“the smallest value is %d”,x);
}
else if(y<z)
{
printf(“the smallest value is %d”,y);
}
else
{
printf(“the smallest value is %d”,z);
}
getch( );
}
output:-

30: program to swap two numbers without function:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int x,y,z;
printf(“enter two numbers to swap:”);
scanf(“%d%d”,&x,&y);
c=a+b;
a=c-a;
b=c-b;
printf(“the values after swapping are: ”a,b);
getch( );
}
output:-

31: program to find power of a number using for loop:-
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int i,x,y,pow=1;
printf(“enter the base”);
scanf(%d”,&x);
printf(“enter the power”);
scanf(“%d”,&y);
for(i=1;i<=y;i++);
{
pow=pow*2;
}rintf(“\n %d^%d=%d”,x,y,pow);
getch( );
}
output:-

so guys i hope you all enjoy these programs and if you enjoy then comment. and please follow me to encourage for next post.
thank you guys..
0 Comments