0% found this document useful (0 votes)
266 views

Programming in C

This document provides examples of C code for basic arithmetic, financial, and conditional programs. It includes programs to add, subtract, multiply, and divide numbers. Other examples calculate simple interest, determine if a year is a leap year, identify positive and negative numbers, check if a number is even or odd, calculate the discriminant of a quadratic equation, compute the area of a circle, and calculate length. Each code example is presented along with sample output to demonstrate the program's functionality.

Uploaded by

sister01
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
266 views

Programming in C

This document provides examples of C code for basic arithmetic, financial, and conditional programs. It includes programs to add, subtract, multiply, and divide numbers. Other examples calculate simple interest, determine if a year is a leap year, identify positive and negative numbers, check if a number is even or odd, calculate the discriminant of a quadratic equation, compute the area of a circle, and calculate length. Each code example is presented along with sample output to demonstrate the program's functionality.

Uploaded by

sister01
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

Programming in C

Submitted by: -
Jitender Singh Negi

Sr. No Shot Name Full name

1. BG Background
2. B Bold
3. I Italic
4. U Underline
5. H1 Head line
6. Li Dotes
7. DD Paragraph
8. Br Break
9. Hr heading Row
10. <i> </i> For Spacing
11. <b> </b> Cell spacing
12 Tr
13. Td Table Data
14. Th Table heading
15. Src Source

Note:- you type all the word in small letter. When you make the program in C
Language.

You type these commands for making a programme in “C”.

This programme for “Add”


#include<stdio.h>
#include<conio.h> Out Put
Void main ( )
C = 50
{
Int a,b,c;
Clrscr( );
a = 20;
b = 30;
c=a+b;
Print f (“sum=%d”,c);
Getch ( );
}

This programme for “Subtract”


#include<stdio.h>
#include<conio.h> Out Put
Void main ( ) C = -10
{
Int a,b,c;
Clrscr ( );
a = 20;
b = 30;
c=a-b;
Print f (“sub=%d”,c);
Getch ( );
}
This programme for “Multiply”

#include<stdio.h> Out Put


C = 600
#include<conio.h>
Void main ( )
{
Int a,b,c;
Clrscr ( );
a = 20;
b = 30;
c=axb;
Print f (“mlt=%d”,c);
Getch ( );
}

This programme for “Divide”

#include<stdio.h>
#include<conio.h> Out Put
Void main ( )
C = 10
{
Int a,b,c;
Clrscr( );
a = 30;
b = 3;
c=a/b;
Print f (“div=%d”,c);
Getch ( );
}

This programme for Arithmetic


#include<stdio.h>
Out Put
a =20
#include<conio.h> b=10
c=30
d=10
e=200
f=2
Void main ( )
{
Int a,b,c,d,e,f;
Clrscr ( );
Printf (”enter two number”);
Scanf(“%d%d”,&a,&b);
c = a+b;
d = a-b;
e=axb;
f=a/b;
Print f (“sum=%d”,c);
Print f (“sub=%d”,d);
Print f (“mul=%d”,e);
Print f (“div=%d”,f);
Getch ( );
}

This programme for find out the interest


#include<stdio.h>
#include<conio.h> Out Put
Void main ( ) Amt. = 1000
{ R=5
T =2
Float amt,r,t,si;
Si = 1000x5x2
Clrscr ( ); 100
Printf (”enter amt,r,t”); = 100/-
Scanf(“%f%f%f”,&amt,&r,&t);
si=amtxrxt/100;
Print f (“simple interest=%f”,si);
Getch ( );
}

This program for find out the Leap year


#include<stdio.h>
Out Put
#include<conio.h> 2008
Not leap year
2006
Leap year
Void main ( )
{
Int a;
Clrscr ( );
Printf (”enter a number”);
Scanf(“%d”,&a);
If (a%4= =0)
{
Print f (“leap year);
}
Else
{
Print f (“not leap year);
}
Getch ( );
}
This program for find out the Positive & Negative Value

#include<stdio.h>
#include<conio.h> Out Put
Void main ( ) 8
{ Positive Number
Int a; -4
Clrscr ( ); Negative Number
Printf (”enter a number”);
Scanf(“%d”,&a);
If (a>=0)
{
Print f (“Positive Number);
}
Else
{
Print f (“ negative number);
}
Getch ( );
}

This program for find out the “Even Number and Odd Put
Out Number”
#include<stdio.h> 2
#include<conio.h> Is even number
5
Is odd number
Void main ( )
{
Int a;
Clrscr ( );
Printf (”enter a number”);
Scanf(“%d”,&a);
If (a%2= =0)
{
Print f (“a is even number);
}
Else
{
Print f (“ a is odd number);
}
Getch ( );
}
This program for find out the Discriminate = b2-4ac

#include<stdio.h>
#include<conio.h> Out Put
Void main ( ) A=10
{ B=5
C=2
Int a,b,c;
D = b2-4ac
Clrscr ( ); = (5)2-4x10x2
Printf (”enter the value=”); = 25-80
Scanf(“%d”,&a); = -55
Printf (”enter the value=”);
Scanf(“%d”,&b);
Printf (”enter the value=”);
Scanf(“%d”,&c);
D=bxb-4xaxc
Printf(“%d”,d);
Getch ( );
}
This program for find out the “Area” Out Put
#include<stdio.h> formula is πr2
R=5
= 3.14x5x5
= 3.14x25
= 78.5
#include<conio.h>
Void main ( )
{
Float p,r,z;
Clrscr ( );
P=3.14;
Printf (”enter the radius= ”);
Scanf(“%f”,&r);
A=pxrxr;
Print f (“area=%f”,a);
Getch ( );
}
This program for find out the “Length”

#include<stdio.h>
#include<conio.h> Out Put
Void main ( ) A=10
{ B=5
C=2
Int a,b,c;
D = b2-4ac
Clrscr ( ); = (5)2-4x10x2
Printf (”enter the value=”); = 25-80
Scanf(“%d”,&a); = -55
Printf (”enter the value=”);
Scanf(“%d”,&b);
Printf (”enter the value=”);
Scanf(“%d”,&c);
D=bxb-4xaxc
Printf(“%d”,d);
Getch ( );
}

You might also like