Add the two No in C
#include<stdio.h>
#include<conio.h>
void main ( )
{
int a ,b,c;
clrscr ( );
a=10;
b=20;
c=a+b;
printf("%d" ,c );
getch( );
}
Write a program to find simple interest
#include<stdio.h>
#include<conio.h>
void main ( )
{
int p , r,t ,i;
clrscr ( );
p=1000;
r =4;
t =5;
i = (p* r* t)/100;
printf("simple interest =%d", i)
getch();
}
int area , len ,bre;
int a, b, c,d ,e, avg;
int a , b;
printf ("enter the value of a ") ;
scanf ("%d",&a);
printf ("enter the value of b");
scanf("%d",&b );
a=a+b;
b=a-b;
a=a-b;
printf("\n after swapping ");
printf("\n the value of a is =%d " ,a);
printf("\n the value of b is =%d " ,b);
getch ( );
}
int n ,r ;
printf("enter the numbers");
scanf("%d", &n);
r = n%10;
printf("%d",&r);
n= n/10;
r= n%10 ;
printf("%d ",r );
n= n/10;
r= n%10 ;
printf("%d",r);
getch( );
}
Write a program to input and print a character
#include<stdio.h>
#include<conio.h>
void main ( )
{
char ch ;
clrscr( );
printf ( "enter the character ");
scanf ("% c",& ch);
printf("Character is =%c ",ch);
getch( );
}
char ch ;
clrscr( );
printf ( "enter the character ");
scanf ("% c",& ch);
printf("Character is =%c ",ch);
getch( );
}
Write a program to input cost & quantity and give 20% discount on total bill
#include<stdio.h>
#include<conio.h>
void main ( )
{
int cost, q, t, d;
printf ( "enter the cost of item") ;
scanf(" %d ",&cost);
printf ( "enter the quantity of item") ;
scanf(" %d ",&q);
t =cost*q;
d=t * 20/100;
printf("\ n your total bill =%d", t);
printf("\ n your discount on bill =%d", d);
printf("\ n your net bill =%d", t-d);
int cost, q, t, d;
printf ( "enter the cost of item") ;
scanf(" %d ",&cost);
printf ( "enter the quantity of item") ;
scanf(" %d ",&q);
t =cost*q;
d=t * 20/100;
printf("\ n your total bill =%d", t);
printf("\ n your discount on bill =%d", d);
printf("\ n your net bill =%d", t-d);
getch ( );
}
Write a program to input length and breadth of a rectangle and calculate its area
#include<stdio.h>
#include<conio.h>
void main ( )
{int area , len ,bre;
printf ("enter the length of rectangle ");
scanf ("%d ",&len);
printf ("enter the breadth of rectangle ");
scanf ("%d ",&bre);
area=len*bre;
printf("area of rectangle is %d", area);
getch ( );
}
Write a program to input age of five persons and find the average of age
#include<stdio.h>
#include<conio.h>
void main ( )
{int a, b, c,d ,e, avg;
printf ("enter the five peson age ");
scanf("%d %d %d %d %d", &a,&b,&c,&d,&e );
avg=(a+b+c+d+e)/5 ;
printf( "average of five persons age is =%d ", avg);
getch ( );
}
Write a program to swap two numbers without using third variable
#include<stdio.h>
#include<conio.h>
void main ( )
{int a , b;
printf ("enter the value of a ") ;
scanf ("%d",&a);
printf ("enter the value of b");
scanf("%d",&b );
a=a+b;
b=a-b;
a=a-b;
printf("\n after swapping ");
printf("\n the value of a is =%d " ,a);
printf("\n the value of b is =%d " ,b);
getch ( );
}
Write a program to print reverse of a three digits no.
#include<stdio.h>
#include<conio.h>
void main ( )
{int n ,r ;
printf("enter the numbers");
scanf("%d", &n);
r = n%10;
printf("%d",&r);
n= n/10;
r= n%10 ;
printf("%d ",r );
n= n/10;
r= n%10 ;
printf("%d",r);
getch( );
}
Write a program to convert centigrade to fahrenheit
#include<stdio.h>
#include<conio.h>
void main ( )
{
float c , f;
printf ("enter the Centigrade");
scanf("%f", &c);
f=(9/5*c) + 32;
print("fahrenheit =% f", f);
}
printf ("enter the Centigrade");
scanf("%f", &c);
f=(9/5*c) + 32;
print("fahrenheit =% f", f);
}
Write a
program to find the size of integer float and character
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int a ;
float b ;
char c;
printf(“\n
size of interger=% d bytes”,sizeof(a));
printf(“\n
size of float=%d bytes”,sizeof(b);
printf(“\n
size of character =%d bytes”,sizeof(c));
getch ( );
}
Write
a program to input the age of a person and find whether he or she is
eligible for voting nor not
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int a ;
printf(“enter
the age of person “);
scanf
(“%d”,& a);
if(a >
18)
{
printf(“you
are eligible for voting ”);
}
else
{
printf(“you
are not eligible for voting ”);
}
getch( );
}
Write a
program to input a number and find whether
the number is positive or negative
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int number ;
printf(“enter
the any number “);
scanf (“%d”,&
number);
if( number
> 0)
{
printf(“number is positive ”);
}
else
{
printf(“number
is negative ”);
}
getch( );
}
Write
a example of if else if statement
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int a , b;
printf(“enter
the two value ”);
scanf(“%d
%d”,&a , &b);
if (a>b)
{
printf(“a
is big”);
}
else if (b >a)
{
printf(“
b is big”);
}
else
{
printf(“a
is equal to b ”);
}
Write a
Program to Enter two number and check
which one is bigger ( using Ternary
Operator)
#include
<sdtio.h>
#include<conio.h>
void main (
)
{
int a , b;
printf(“enter
the two value ”);
scanf(“%d
%d”,&a , &b);
(a>b) ?
printf(“a is big ”) : printf( “b is big “);
getch( );
}
Write a
program using switch – case statement
#include
<stdio.h>
#include<conio.h>
void main (
)
{
char a ;
printf(“enter
the value of a”);
scanf(“%d”,&a
);
switch (a)
{
case ‘r’ :
printf(
“colour is red ”);
break ;
case ‘w’ :
printf(
“colour is white ”);
break ;
case ‘g’ :
printf(
“colour is green”);
break ;
case ‘b’ :
printf(
“colour is blue ”);
break ;
default :
printf(
“colour is not in this series ”);
getch ( );
}
Write a
program to enter the character and
check if it is a vowel or not
#include
<stdio.h>
#include<conio.h>
void main (
)
{
char c ;
printf(“enter
the value of c”);
scanf(“%d”,&c);
switch (c)
{
case ‘a’ :
case ‘ i ’
:
case ‘ o ’
:
case ‘ u ’
:
case ‘ e ’
:
printf(“it
is vowel ”);
break ;
default:
printf(“no
is not vowel ”);
}
getch( );
}
Write a
program to print 1 to 10 digit (using
for loop)
#include
<stdio.h>
#include<conio.h>
void main (
)
{
Int a ;
for (a= 1;
a<=10 ;a ++)
{
printf(“ \n
this is the for loop program “);
}
getch ( );
}
Write a
program to display the A to Z letter
using the for loop
#include
<stdio.h>
#include<conio.h>
void main (
)
{
char c ;
for (c=’A’;
c<=’Z’; c++)
{
printf(“ %c
”, c);
}
getch ();
}
Write a
program to print the format given below
1
12
123
1234
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int a,n=0 ;
clrscr();
for(a=1;a<=4;a++)
n=n*10+a;
printf(“\n
%d”,n );
}
getch( );
}
Write a
program to count the even number between
two given numbers
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int start ,
end, i,c=0;
printf(“enter
the start no”);
scanf(“%d”,&
start);
printf(“enter
the ending no”);
scanf(“%d”,&end);
for
(i=start;i<end;i++)
{
If (i%2==0)
{
c++;
}
}
printf(“total
even no is =%d”,c);
getch();
}
Write a
program to print series 2,4,8,16----------
using the while loop
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int a=2;
while
(a<=50)
{
printf(“%d’,&a);
a=a*2;
}
getch( );
}
Write a
program to find the factorial no for
eg 5=(5*4*3*2*1)=120
#include
<stdio.h>
#include<conio.h>
void main (
)
{
Int n ,i
,f=1;
clrscr( );
printf(“enter
the any no ”);
scanf(“%d”,n);
i=n;
while
(i>1)
{
f=f * i;
i--;
}
printf(“factorial
no is =%d”,f);
getch();
}
Write a
program to convert a decimal number into
binary number
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int
n,c=10,r;
clrscr( );
printf(“enter
the decimal number”);
scanf(“%d”,&n);
while
(n>0)
{
r=n%2;
gotoxy(c,3);
// gotoxy is the inbuilt () which take two parameters which is represent x ,y
co ordinates
printf(“%d”
,r);
c--;
n=n/2;
}
getch( );
}
Write a
program to print counting from 1 to 10 using while loop
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int a;
clrscr();
a=1;
do{
printf(“%d”
, a);
a++;
}
while(a<=10)
getch();
}
Write a
program of infinte loop
#include
<stdio.h>
#include<conio.h>
void main (
)
{
for (
; ; )
{
printf(“this
is the program of infinite”);
}
getch();
}
Write a
program to print following
1
12
123
1234
12345
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int i , j;
for
(i=0;i<5;i++)
{
for
(j=0;j<i;j++)
{
printf(“%d”,i);
}
printf(“\n”);
}
getch( );
}
Write a
program of simple array
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int a[5],i
;
for
(i=0;i<5;i++)
{
printf(“enter
the number”);
scanf(“%d”,&a[i]);
}
for
(i=0;i<5;i++)
{
printf(“\n
%d”,a[i]);
}
getch( );
}
Write a
program to sort an array
#include
<stdio.h>
#include<conio.h>
void main (
)
{
int a[5],i
,j,t;
for
(i=0;i<5;i++)
{
printf(“enter
the number”);
scanf(“%d”,&a[i]);
}
for
(i=0;i<5;i++)
{
for (j=j+1;
j<5; j++)
{
If(a[i]>a[j])
{
t= a[i];
a[i]=a[j];
a[j]=t;
}}}
for
(i=0;i<5;i++)
{
printf(“\t
%d”,a[i])
}
getch( );
}
Write a
program to input and print a string
#include
<stdio.h>
#include<conio.h>
void main (
)
{
char
ch[20];
clrscr();
printf(“enter
the name”);
scanf(“%s”,&ch)
printf(“the
name is =%s”,ch);
getch();
}
Write a
program to reverse a string
#include
<stdio.h>
#include<conio.h>
void main (
)
{
char a[20],c;
int I,j;
printf(“enter
the any string”);
scanf(“%s”,a
);
for(i=0;
a[i]!=’\0’; i++ )
{
c=c+1;
}
for(j=0;j>0;
j--)
{
printf(“%c”,a[j]);
}
getch();
}
Write a
program of gets and puts
#include
<stdio.h>
#include<conio.h>
void main (
)
{
char a[20];
printf(“enter
the any string”);
gets(a);
puts(a);
getch();
}
Write a
program to find a length of string
#include
<stdio.h>
#include<conio.h>
#include<string>
void main (
)
{
char a[20];
int I;
printf(“enter
the any string”);
scanf(“%s”,&a);
i=strlen(a);
printf(“the
string length is =%d”,i);
getch();
}
Write a
program of inbuilt sqrt()
#include
<stdio.h>
#include<conio.h>
#include<math.h>
void main (
)
{
int i ;
printf(“enter
the any value”);
scanf(“%d”,&i);
printf(“square root of the number i=%d”,sqrt(i));
getch();
}
Write a programe to simple Functon
#include
<stdio.h>
#include
<conio.h>
void sum ( ); // function
declaration
void main
{
Clrscr();
Sum ()
; //
function calling
getch ();
}
void sum ( ) // function definition
{
Int a , b,
c;
printf( “
enter the two no “);
scanf(“%d %d”,&a &b);
c=a+b;
printf
(“sum is %d “, c);
}
Write a program of pointer
#include
<stdio.h>
#include
<conio.h>
void main( )
{
Int a ,*b;
a = 10;
b = &a;
printf (
“\n the value of a =%d”, a );
printf (“\n
the address of a =%u”, &a);
getch ( );
}
Write a program
using with structure.
#include<stdio.h>
#include<conio.h>
struct student
{
char name[20];
int roll, marks;
};
void main()
{
struct student
s;
clrscr();
printf(“Enter
student name”) ;
scanf(“%s”,&s.name);
printf(“Enter
student roll no”);
scanf(“%d”,&s.roll);
printf(“Enter
student marks”);
scanf(“%d”,&s.marks);
print(“\n your
name=%s”,s.name);
printf(“\n your
roll=%d”,s.roll);
printf(“\n your
marks=%d”,s.marks);
getch();
}
Write a program of union
#include<stdio.h>
#include<conio.h>
union
student
{
char name[20];
int roll ,
marks;
};
void main()
{
union
student s;
clrscr();
s .name =' h';
printf ("\n your name =%c ",s.name );
s.roll=1;
printf ("\n your rollno =%d ",s.roll );
s.marks=100;
printf ("\n your marks =%d ",s.marks);
}
printf ("\n your name =%c ",s.name );
s.roll=1;
printf ("\n your rollno =%d ",s.roll );
s.marks=100;
printf ("\n your marks =%d ",s.marks);
}
Write a program of Enumeration
#include<stdio.h>
#include<conio.h>
enum color{red ,green , black ,white};
{
void main ( )
{
clrscr();
printf("\n the value of red =%d",red);
printf("\n the value of green =%d",green);
printf("\n the value of white =%d",white);
}
#include<conio.h>
enum color{red ,green , black ,white};
{
void main ( )
{
clrscr();
printf("\n the value of red =%d",red);
printf("\n the value of green =%d",green);
printf("\n the value of white =%d",white);
}
Write a program of FIEL handling
#include
<stdio.h>
#include
<conio.h>
void main ( )
{
char
str[20];
FILE *fp;
clrscr ()
printf
(“enter the any string “);
gets(str );
fp=fopen(“deep.txt”,”
w”);
fputs (str
, fp);
printf (
“data is written into the file :”);
fclose
(fp);
getch();
}








0 comments:
Post a Comment