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

Katrina Kaif: M.Tech

Uploaded by

sathyam.chavan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Katrina Kaif: M.Tech

Uploaded by

sathyam.chavan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 113

SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE

SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAMMING IN C LAB RECORD (CS-210)

AIM: Write a C program to print your name.

PROCEDURE:

ALGORITHM:

Step1: Start the program.

Step 2: Print KATRINA KAIF.

Step-3: End of the program.

FLOW CHART:
start

Print KATRINA KAIF.

End

PROGRAM:

// C program on printing your name

#include<stdio.h>

#include<conio.h>

void main() {

clrscr();

printf(“KATRINA KAIF”);

getch(); }

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 1


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to print using arithmetic operators by using integer


datatype.

PROCEDURE:

ALGORITHM:

Step1: Start the program.

Step2: Read a,b values.

Step3: Compute and print the sum of a and b.

Step4:Compute and print the subtraction of b from a.

Step5: Compute and print the product of a and b.

Step6:Compute and print the division of a by b.

Step7: Compute and print a modulus b.

Step8: End of the program.

FLOWCHART: Start

Declare a,b

Read a,b values

Compute, c=a+b

d=a-b

g=a%b

e=a*b

f=a/b

print c, d, g, e, f

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 2


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

//program on arithmetic operators using integer datatype

#include<stdio.h>

#include<conio.h>

void main(){

int a,b,c,d,e,f,g;

clrscr();

printf("---Arithmetic operators---");

printf("\n enter a,b values");

scanf("%d%d",&a,&b);

c=a+b;

d=a-b;

e=a*b;

f=a/b;

g=a%b;

printf("\n%d+%d=%d",a,b,c);

printf("\n%d-%d=%d",a,b,d);

printf("\n%d*%d=%d",a,b,e);

printf("\n%d/%d=%d",a,b,f);

printf("\n%d %%d=%d",a,b,g);

getch(); }

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 3


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM:Write a C Program to print using Arithmetic Operations by using Float


datatype.

PROCEDURE:

ALGORITM:

Step 1: Start the Program

Step 2: Read a and b values

Step 3: Compute the Sum of a and b and store the value in variable c

Step 4: Compute difference of a and b and store value in variable d

Step 5: Compute the product of a and b and store the value in variable e

Step 6: Divide a value by b and store the value in variable f

Step 7: Print the values of variables c,d,e and f.

Step 8: End of the program.

FLOWCHART:
Start

Read a,b values

Compute, c=a+b

d=a-b

e=a*b

f=a/b

Print c,d,e and f values

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 4


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

//Arithmetic Operators using Float

#include<stdio.h>

#include<conio.h>

void main() {

float a,b,c,d,e,f;

clrscr();

printf("_____Arithmetic Operators on Float______");

printf("\nEnter a and b values:");

scanf("%f %f",&a,&b);

c=a+b;

printf("\n %f+%f=%f",a,b,c);

d=a-b;

printf("\n %f-%f=%f",a,b,d);

e=a*b;

printf("\n %f*%f=%f",a,b,e);

f=a/b;

printf("\n %f/%f=%f",a,b,f);

getch(); }

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 5


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to print using Arithmetic operators by using


character datatype.

PROCEDURE:

ALGORITHM:

Step1: Start the program.

Step2: Read the values of characters a, b.

Step3: Compute the sum of a, b and store the value in variable c .

Step4: Print the value of ‘c’.

Step5: Compute the difference of a, b and store it in variable d.

Step6: Print the value of ‘d’.

Step7: Compute the product of a, b and store the value in variable e.

Step8: Print the value of ‘e’.

Step9: Compute the division value of a,b and store the value in variable f.

Step10: Print the value of ‘f’.

Step11: Compute the modulus of a, b and store it in variable g.

Step12: Print the value of ‘g’.

Step13: End of the program.

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 6


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

FLOWCHART:

Start

Read a, b values

c= a+b

Print c value

d= a-b

Print d value

e= a*b

Print e value

f= a/b

Print f value

g= a%b

Print g value

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 7


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

// C program on Arithmetic operators using char


#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
char a,b,c,d,e,f,g;
clrscr();
printf("\n____Arithematic operators on char datatype____");
printf("Enter the values of a and b: ");
scanf("%c %c",&a,&b);
c=a+b; d=a-b; e=a*b; f=a/b; g=a%b;
printf("\n%c+%c= %c",a,b,c);
printf("\n%c-%c= %c",a,b,d);
printf("\n%c*%c= %c",a,b,e);
printf("\n%c/%c= %c",a,b,f);
printf("\n%c mod %c= %c",a,b,g);
getch();
}
OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 8


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to print and to solve the Quadratic equation


s=a*x*x+b*x+c.

PROCEDURE:
ALGORITHM:

Step1: Start of the program.

Step2: Declare variables a, b, c, s, x;

Step3:Read a, b, c, x;

Step4: Store a*x*x+b*x+c in s variable

Step5: print s

Step8: End of the program.

FLOWCHART:

Start

Declare a, b, c, s, x

Read a, b, c, x

Compute s=a*x*x+b*x+c

print s

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 9


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

#include<stdio.h>

#include<conio.h>

void main()

int a,b,c,x,s;

clrscr();

printf("enter a,b,c,x value=");

scanf("%d %d %d %d",&a,&b,&c,&x);

s=(a*x*x)+(b*x)+c;

printf("s=(%d*%d*%d)+(%d*%d)+%d=%d",a,x,x,b,x,c,s);

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 10


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

12𝑥 3 8𝑥 2 𝑥 8
AIM: Write a C program to solve the given equation.X = 4𝑥
+ 4𝑥
+ 4𝑥 + 4𝑥

PROCEDURE:

ALGORITHM:

Step1: Start of the program

Step2: Declare a, b, c, d, e, x

Step3: Read x

Step4: Compute a = (12*x*x*x)/(4*x)

Step5: Compute b = (8*x*x)/(4*x)

Step6: Compute c = x/(4*x)

Step7: Compute d = 8/(4*x)

Step8: Compute e = a+b+c+d

Step9: Print X = variable ‘e’ value

Step10: End of the program.

FLOW CHART:

Start

Declare
a,b,c,d,e,x

Read x

Compute a =
(12*x*x*x)/(4*x)

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 11


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

Compute b =
(8*x*x)/(4*x)

Compute c =
x/(4*x)

Compute d =
8/(4*x)

Compute =
a+b+c+d

Print x = Variable ‘e’


value

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 12


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

//C program to solve the given equation.

#include<stdio.h>

#include<conio.h>

void main()

float a,b,c,d,e,x;

clrscr();

printf(“\n enter x value= ”);

scanf(“%f”,&x);

a=(12*x*x*x)/4*x;

b=(8*x*x)/4*x;

c=x/(4*x);

d=8/(4*x);

e=a+b+c+d;

printf(“\n 12*x*x*x 8*x*x x 8 ”);

printf(“\n --------- + ------ + -- + --”);

printf(“\n 4x 4x4x4x \n”);

printf(“\n 12*%.2f*%.2f*%.2f 8*%.2f*%.2f %.2f 8 ”,x,x,x,x,x,x);

printf(“\n ---------------------- + -------------- + -------- + --------- = %.2f”,e);

printf(“\n 4*%.2f 4*%.2f 4*%.2f 4*%.2f”,x,x,x,x);

getch();

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 13


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 14


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program using Relational Operators.

PROCEDURE:

ALGORITHM:

Step1: Start the program.

Step2: Declare and Read a, b values.

Step3: Store a greater than b in c variable.

Step4: Print the value of c variable.

Step5: Store a less than b in c variable.

Step6: Print the value of c variable.

Step7: Store a greater than equal to b in c variable.

Step8: Print the value of c variable.

Step9: Store a less than equal to b in c variable.

Step10: Print the value of c variable.

Step11: Store a not equal to b in variable c.

Step12: Print the value of c variable.

Step13: Store a double equal to b in variable c.

Step14: Print the value of c variable.

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 15


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

FLOWCHART:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 16


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

//C program using relational operators


#include<stdio.h>
#include<conio.h>
void main()
{
inta,b,c;
clrscr();
printf("a,b values=");
scanf("%d%d",&a,&b);
printf(" RELATIONAL OPERATOR ");
c=(a<b);
printf("\n%d>%d=%d",a,b,c);
c=(a>b);
printf("\n%d<%d=%d",a,b,c);
c=(a>=b);
printf("\n%d>=%d=%d",a,b,c);
c=(a<=b);
printf("\n%d<=%d=%d",a,b,c);
c=(a!=b);
printf("\n%d!=%d=%d",a,b,c);
c=(a==b);
printf("\n%d==%d=%d",a,b,c);
getch();
}
OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 17


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM:-Write C program using Logical operators.

PROGRAM:

ALGORITHM:

Step-1:-Start the program.

Step-2:-Read a,b values

Step-3:-Store(a>b)&&(a<b) value in variable c.

Step-4:- Print variable c.

Step-5:-store(a>b)&&(a>b) value in variable c.

Step-6:-print c.

Step-7:- store(a<b)&&(a<b) value in variable c.

Step-8:- print variable c

Step-9: store(a<b)&&(a>b) value in variable c.

Step10: print variable c.

Step11: store(a>b)||(a<b) value in variable c.

Step12: print variable c.

Step13: store(a>b)||(a>b) value in variable c.

Step14: print c.

Step15: store(a<b)||(a<b) value in variable c.

Step16: print variable c

Step17: store(a<b)||(a>b) value in variable c.

Step18: print variable c.

Step19: store!(a>b)value in variable c.

Step20: Print variable c

Step21: Store !(a<b) value in variable c.

Step22: Print variable c.

Step23: End the program.

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 18


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

FLOW CHART:-
start

Declare a,bvariables

Read a,b values

C=(a>b)&
TRUE &(a<c) FALSE

Print c=1 print c=0

TRUE FALSE
c=(a>b)&&
(a>b)

Print c=1 Print c=0

C=(a<b)&&
TRUE (a<b) FALSE

Print c=1 Print c=0

TRUE FALSE
C=(a>b&&(
a<b)

Print c=1 Print c=0

TRUE FALSE
C=(a>b)||(
a<b)

Print c=1 Print c=0

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 19


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

TRUE c=(a>b)||( FALSE


a>b)

Print c=1 Print c=0

TRUE FALSE
c=(a<b)||(
a<b)

Print c=1 Print c=0

c=(a<b)||(a
TRUE >b) FALSE

Print c=1 Print c=0

TRUE FALSE
c=!(a>b)

Print c=1 Print c=0

TRUE FALSE
C=!(a<b)

Print c=1 Print c=0

END

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 20


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:-

// C program using logical operators.

#include<stdio.h>

#include<conio.h>

void main()

int a,b,c;

clrscr();

printf(“___Logical operators___”);

printf("\nEnter a,b values=");

scanf("%d%d",&a,&b);

printf(“\nLogical And”);

c=(a>b)&&(a>b);

printf("\n(%d>%d)&&(%d>%d)=%d\n"a,b,c);

c=(a<b)&&(a<b);

printf("\n(%d<%d)&&(%d<%d)=%d\n"a,b,c);

c=(a<b)&&(a>b);

printf("\n(%d<%d)&&(%d>%d)=%d\n"a,b,c);

c=(a>b)&&(a<b);

printf("\n(%d>%d)&&(%d<%d)=%d\n"a,b,c);

printf(“\nLogical or”);

c=(a>b)||(a>b);

printf("\n(%d>%d)||(%d>%d)=%d\n"a,b,c);

c=(a<b)||(a<b);

printf("\n(%d<%d)||(%d<%d)=%d\n"a,b,c);

c=(a<b)||(a>b);

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 21


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

printf("\n(%d<%d)||(%d>%d)=%d\n"a,b,c);

c=(a>b)||(a<b);

printf("\n(%d>%d)||(%d<%d)=%d\n"a,b,c);

printf(“\nLogical not”);

c = !(a>b)

printf(“!(%d>%d)=%d”,a,b,c);

c = !(a<b)

printf(“!(%d<%d)=%d”,a,b,c);

getch();

OUTPUT:-

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 22


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM:Write a C program using Assignment operators.

PROCEDURE:

ALGORITHM:

STEP-1: Start the program

STEP-2: read a,b values

STEP-3: compute sum of a,b and store in variable a

STEP-4: print value of a

STEP-5: compute a-b and store in variable a

STEP-6: print a value

STEP-7: compute a*b and store in variable a

STEP-8: print a value

STEP-9: compute a/b and store in variable a

STEP-10: print a value

STEP-11: compute a%b and store in variable a

STEP-12: print a value

STEP-13: End of the program

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 23


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

FLOWCHART:

Start

Read a,b values

a+=b

Print a value

a-=b

Print a value

a*=b

Print a value

a/=b

Print a value

a%=b

Print a value

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 24


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

// C Program using Assignment operators

#include<stdio.h>

#include<conio.h>

void main ()

int a,b;

printf(“enter a and b values”);

scanf(“%d%d”,&a,&b);

printf(“\n---assignment operators---”);

printf(“\n%d+=%d”,a,(a+=b));

printf(“\n%d-=%d”,a,(a-=b));

printf(“\n%d*=%d”,a,(a*=b));

printf(“\n%d/=%d”,a,(a/=b));

printf(“\n%dmod=%d”,a,(a%=b));

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 25


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM :Write a C program using Bitwise operator.

PROCEDURE :

ALGORITHM :

Step 1: Start the program.

Step 2 :Read a, b values.

Step 3 : Compute a and b bit value and store it in c.

Step 4 : Compute a or b bit value and store it in d.

Step 5 : Compute a left shift b bit value and store it in variable e.

Step 6 : Compute a right shift b bit value and store in variable f.

Step 7 : Compute a excusive or b bit value and store it in variable g.

Step 8 : Compute one`s compliment of a and store in h.

Step 9 : Print c, d, e, f, g, h values.

FLOW CHART : Start

Read a, b values

c=a&b

d=a|b

e=a<<b

f=a>>b

g=a^b

h=~a

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 26


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

Read c, d, e, f, g
and h values

Stop

PROGRAM:

//C- Program using bitwise operators

#include<stdio.h>

#include<conio.h>

void main()

int a,b,c,d,e,f,g,h;

clrscr();

printf("Enter a,b values\n");

scanf("%d%d",&a,&b);

c=a&b;

d=a|b;

e=a<<b;

f=a>>b;

g=a^b;

h=~a;

printf("a&b =%d\n",c);

printf("a|b =%d\n",d);

printf("a<<b =%d\n",e);

printf("a>>b =%d\n",f);

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 27


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

printf("a^b =%d\n",g);

printf("~a =%d\n",h);

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 28


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to convert a number from Decimal to Binary form.

PROCEDURE:

ALGORITHM:

Step1: Start of the program.

Step2: Declare the a value.

Step3: Read the a value.

Step4: Print Decimal to Binary Conversation

Step5: Print Enter the a value =

Step6: Print Binary code of a is

Step7: now by using bitwise operator (a&256)>>8

Step8: (a&128)>>7

Step9: (a&64)>>6

Step10: (a&32)>>5

Step11: (a&16)>>4

Step12: (a&8)>>3

Step13: (a&4)>>2

Step14: (a&2)>>1

Step15: (a&1)>>0

Step16: Print binary number

Step17: End of the program.

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 29


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

FLOWCHART:
Start

Declare a value

Read a value

Print (a&256)>>8

Print (a&128)>>7

Print (a&64)>>6

Print (a&32)>>5

Print (a&16)>>4

Print (a&8)>>3

Print (a&4)>>2

Print (a&2)>>1

Print (a&1)>>0

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 30


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

//convertion of decimal to binary

#include<stdio.h>

#include<conio.h>

void main()

int a;

clrscr();

printf(" Decimal to Binary Conversation\n");

printf(" Enter the value of a =");

scanf("%d",&a);

printf("\n Binary code of a is ");

printf("\n %d",(a&256)>>8);

printf("%d",(a&128)>>7);

printf("%d",(a&64)>>6);

printf("%d",(a&32)>>5);

printf("%d",(a&16)>>4);

printf("%d",(a&8)>>3);

printf("%d",(a&4)>>2);

printf("%d",(a&2)>>1);

printf("%d",(a&1)>>0);

getch();

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 31


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 32


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program using Increment and Decrement operators.

PROCEDURE:

ALGORITHM:

Step1:Start of the program.

Step2:Read the values of a,b.

Step3:print the value of (a++)+(++b).

Step4:print the value of (a++)-(++b).

Step5:print the value of (a--)+(--b).

Step6:print the value of (a--)-(--b).

Step7:print the value of (a++)*(++b).

Step8:print the value of (a++)/(++b).

Step9:print the value of (a--)*(--b).

Step10:print the value of (a--)/(--b).

Step11:print the value of a++, ++a , --a, a--.

Step12:print the value of b++, ++b , --b, b--.

Step13:End of the program .

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 33


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

FLOW CHART: Start

Read a,b,c value

a=a++

print a value

a=++a

print a value

a=a--

print a value

a=--a

print a value

b=b++

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 34


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

print b value

b=++b

print b value

b= b--

print b

b=--b

print b

c=(a++)+(++b)

print c

c=(a++)-(++b)

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 35


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

print c

c=(a--)+(--b)

print c

c=(a--)-(--b)

print c

c=(a++)*(++a)

print c

c=(a++)/(--a)

print c

c=(a--)*(--b)

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 36


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

print c

c=(a--)/(--b)

end

PROGRAM:
#include< stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("enter a,b:");
scanf("%d%d",&a,&b);
clrscr();
printf("\n (%d++)+(++%d)=%d",a,b,(a++)+(++b));
printf("\n (%d++)-(++%d)=%d",a,b,(a++)-(++b));
printf("\n (%d--)+(--%d)=%d",a,b,(a--)+(--b));
printf("\n (%d--)-(--%d)=%d",a,b,(a--)-(--b));
printf("\n (%d++)*(++%d)=%d",a,b,(a++)*(++b));
printf("\n (%d++)/(++%d)=%d",a,b,(a++)/(++b));
printf("\n (%d--)*(--%d)=%d",a,b,(a--)*(--b));
printf("\n (%d--)/(--%d)=%d",a,b,(a--)/(--b));
printf("\n (++%d)=%d",a,(++a));
printf("\n (%d++)=%d",a,(a++));
printf("\n (--%d)=%d",a,(--a));
printf("\n (%d--)=%d",a,(a--));
printf("\n (++%d)=%d",b,(++b));
printf("\n (%d++)=%d",b,(b++));
printf("\n (--%d)=%d",b,(--b));
printf("\n (%d--)=%d",b,(b--));
getch( );
}

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 37


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 38


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM :Write a C program to print using Conditional operators

PROCEDURE:-

ALGORITHM :

Step 1: Start the program

Step 2: Declare a, b, c, age, weight, year, mod

Step 3: Read a value

Step 4: Check a mod 2==0,if true print even number ,if false print odd
number

Step 5: Read a value

Step 6: Check a greater than 0 ,if true print positive number,if false print
negative number

Step 7: Read a,b,c values

Step 8: Check a greater than b and a greater than c if true print a greater or
b greater than a and b greater than c if true print b is greater ,if false print c
is greater

Step 9: Read year value

Step 10: Check year mod 4==0 if true print leap year,if false print not leap
year

Step 11: Read age value

Step 12: Check age greter than 18 if true print eligible ,if false print not
eligible

Step 13: Read nod value

Step 14: Check nod is greater than or equal to 2 if true print egilible,if false
print not eligible

Step 15: Read age value

Step 16: Check age greater than 18 if true print eligible,if false print not
eligible

Step 17: Read a value

Step 18: Check a==0 or a==1 if true print neither prime nor composite,if

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 39


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

false check a mod 2 greater than 0 or a==2 and a mod 3 greater than 0 or
a==3 and a mod 5 greater than 0 or a==5 and a mod 7 greater than 0 or
a==7 if true print prime,if false print composite

Step 19: End of the program

PROGRAM :

#include<stdio.h>

#include<conio.h>

void main()

int a,b,c,age,weight,year,nod;

clrscr();

printf("\n____conditional operators___");

printf("\n_____even or odd_____");

printf("\nenter a value=");

scanf("%d",&a) ;

(a%2==0)?printf("even number"):printf("odd number");

printf("\n_____positive or negative_____");

printf("\nenter a value=");

scanf("%d",&a);

(a>0)?printf("positive number"):printf("negative number");

printf("\n_____greatest among three_____");

printf("\n enter a,b,c values=");

scanf("%d%d%d",&a,&b,&c);

(a>b)&&(a>c)?printf("%d is greater",a):(b>a)&&(b>c)?printf("%d is
greater",b):printf("%d is grater",c);

printf("\n_____Leap year____");

printf("\nenter year=");

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 40


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

scanf("%d",&year);

(year%4==0)?printf("leap year"):printf("not a leap year");

printf("\n____covid first dose______");

printf("\n enter the age=");

scanf("%d",&age);

(age>=18)?printf("eligible"):printf("not elgible");

printf("\n_______blood donation______");

printf("\nenter the age and weight=");

scanf("%d%d",&age,&weight);

(age>=18)&&(age<55)&&(weight>50)?printf("eligible for donation"):printf("not


eligible");

printf("\n___Booster dose____");

printf("\nenter no of doses=");

scanf("%d",&nod);

(nod>=2)?printf("eligible"):printf("not eligible");

printf("\n___voting____");

printf("\nenter the age=");

scanf("%d",&age);

(age>18)?printf("eligible"):printf("not eligible");

printf("\n______prime or composite____");

printf("\n enter a number=");

scanf("%d",&a);

(a==0||a==1)?printf("neither prime nor


composite"):(a%2>0||a==0)&&(a%3>0||a==3)&&(a%5>0||a==5)&&(a%7>0|
|a==7)?printf("%d is a prime",a):printf("%d is composite",a);

getch();

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 41


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

OUTPUT :

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 42


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program using Special operators by using all data types.

PROCEDURE:

ALGORITHM:

STEP-1: Start the program

STEP-2: Declare the variables as a, b, c, d, e, f, g, h, I, j, k, l, m, n with

different types

STEP-3: Print the size and address of variable ‘a’ which is in ‘int’ data

type

STEP-4: Print the size and address of variable ‘b’ which is in ‘short int’

data type

STEP-5: Print the size and address of variable ‘c’ which is in ‘unsigned

int’ data type

STEP-6: Print the size and address of variable ‘d’ which is in ‘unsigned

short int’ data type

STEP-7: Print the size and address of variable ‘e’ which is in ‘long int’

data type

STEP-8: Print the size and address of variable ‘f’ which is in ‘unsigned

long int’ data type

STEP-9: Print the size and address of variable ‘g’ which is in ‘long long

int’ data type

STEP-10: Print the size and address of variable ‘h’ which is in ‘usigned

long long int’ datatype

STEP-11: Print the size and address of variable ‘i’ which is in ‘char’ data

type

STEP-12: Print the size and address of variable ‘j’ which is in ‘unsigned

char’ data type

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 43


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

STEP-13: Print the size and address of variable ‘k’ which is in ‘signed

char’ data type

STEP-14: Print the size and address of variable ‘l’ which is in ‘float’ data

type

STEP-15: Print the size and address of variable ‘m’ which is in ‘double’

data type

STEP-16: Print the size and address of variable ‘n’ which is in ‘long

double’ data type

STEP-17: End the program

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 44


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

FLOWCHART:

Start

Declare variables
int a,
short int b,
unsigned int c,
unsigned short int d,
long int e,
unsigned long int f,
long long g,
unsigned long long int h,
char I,
unsigned char j,
signed char k,
float l,
double m,
long double n

Print size and address of a variable

Print size and address of a variable b

Print size and address of a variable c

Print size and address of a variable d

Print size and address of a variable e

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 45


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

Print size and address of a variable f

Print size and address of a variable g

Print size and address of a variable h

Print size and address of a variable i

Print size and address of a variable j

Print size and address of a variable k

Print size and address of a variable l

Print size and address of a variable m

Print size and address of a variable n

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 46


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

//c program on special operators using all data types


#include<stdio.h>
#include<conio.h>
void main()
{
int a;
short int b;
unsigned int c;
unsigned short int d;
long int e;
unsigned long int f;
long long int g;
unsigned long long int h;
char i;
unsigned char j;
signed char k;
float l;
double m;
long double n;
clrscr();
printf("\n Size of int = %d",sizeof(a));
printf("\n Address of int = %u",&a);
printf("\n Size of short int = %d",sizeof(b));
printf("\n Address of short int = %u",&b);
printf("\n Size of unsigned int = %d",sizeof(c));
printf("\n Address of unsigned int = %u",&c);
printf("\n Size of unsigned short int = %d",sizeof(d));
printf("\n Address of unsigned short int = %u",&d);
printf("\n Size of long int = %d",sizeof(e));
printf("\n Address of long int = %u",&e);
printf("\n Size of unsigned long int = %d",sizeof(f));
printf("\n Address of unsigned long int = %u",&f);
printf("\n Size of long long int = %d",sizeof(g));
printf("\n Address of long long int = %u",&g);
printf("\n Size of unsigned long long int = %d",sizeof(h));
printf("\n Address of unsigned long long int = %u",&h);
printf("\n Address of char = %u",&i);
printf("\n Size of unsigned char = %d",sizeof(j));
printf("\n Address of unsigned char = %u",&j);
printf("\n Size of signed char = %d",sizeof(k));

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 47


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

printf("\n Address of signed char = %u",&k);


printf("\n Size of char = %d",sizeof(i));
printf("\n Size of float = %d",sizeof(l));
printf("\n Address of float = %u",&l);
printf("\n Size of double = %d",sizeof(m));
printf("\n Address of double = %u",&m);
printf("\n Size of long double = %d",sizeof(n));
printf("\n Address of long double = %u",&n);
getch();
}
OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 48


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM:-Write a C program to print the Area of circle , Simple interest and to


convert Celsius to Fahrenheit, and Fahrenheit to Celsius.

ALGORITHM:-

Step-1:-Start the program.

Step-2:-Declare r, area,si,p,t,r,c,f values.

Step-3:-Read r value.

Step-4:-Compute area=3.14*r*r and store it in area.

Step-5:-print area value.

Step-6:-Read p, t, r values.

Step-7:-Compute si=(p*t*r)/100 and store in it si.

Step-8:-Print si value.

Step-9:-Read c value.

Step-10:-Compute f=c*1.800+32.00 and store it in f.

Step-11:-Print f value.

Step-12:-Read f value.

Step-13:-Compute c=f-32/1.800 and store it in c.

Step-14:-print c value.

Step-15:-End of the program.

FLOW CHART:-

Start

Read r value

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 49


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

Compute
area=3.14*r*r

Print area

Read p,t,r values

Compute
si=(p*t*r)/100

Print si value

Read c value

Compute
f=c*1.800+32.00

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 50


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

Print f value

Read f value

Compute
c=f-32/1.800

Print c value

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 51


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

#include<stdio.h>

#include<conio.h>

void main()

float r,area,si,p,t,rt,c,f;

clrscr();

printf("\nenter the r value=");

scanf("%f",&r);

area=3.14*r*r;

printf("\narea=%f",area);

printf("\nenter the values of p,t and r=");

scanf("%f%f%f",&p,&t,&rt);

si=(p*t*rt)/100;

printf("\nsimple interest=%f",si);

printf("\nenter the value of c=");

scanf("%f",&c);

f=(c*1.800)+32.00 ;

printf("\nfahrenheit=%f",f);

printf("\nenter the value of f=");

scanf("%f",&f);

c=(f-32)/1.800;

printf("\ncelcius=%f",c);

getch();

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 52


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 53


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to print the Multiplication table of a number.

PROCEDURE:

ALGORITHM:

Step 1: start of the program.

Step 2: Read a values

Step 3: equate b as b = 1.

Step 4: multiply a&b then store in c and print c.

Step 5: Increment b by 1 then go to Step4.

Step 6: Repeat same procedure upto 10 numbers

Step 7: End of the program

FLOWCHART:

start

Read a,b values

C=a*b

Increment by 1

yes
Is b<11

no
Print c value

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 54


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

//print table of a number

#include<conio.h>

#include<stdio.h>

void main()

int a,b=1;

clrscr();

printf("enter a value(table)");

scanf("%d",&a);

printf("\n%d*%d=%d",a,b,(a*b));

printf("\n%d*%d=%d",a,b,(a*++b));

printf("\n%d*%d=%d",a,b,(a*++b));

printf("\n%d*%d=%d",a,b,(a*++b));

printf("\n%d*%d=%d",a,b,(a*++b));

printf("\n%d*%d=%d",a,b,(a*++b));

printf("\n%d*%d=%d",a,b,(a*++b));

printf("\n%d*%d=%d",a,b,(a*++b));

printf("\n%d*%d=%d",a,b,(a*++b));

printf("\n%d*%d=%d",a,b,(a*++b));

getch();

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 55


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 56


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM : Write a C program on multiplication of two numbers.


PROCEDURE :

ALGORITHM :

Step 1 : Start the program.


Step 2 : Read a,b values
Step 3 : print a,b values
Step 4 : compute b%10 value
Step 5 : multiply the value with a and store in c
Step 6 : print the value of variable
Step 7 : compute b/10 value
Step 8 : multiply the value with a and store in d
Step 9 : print the value of variable d
Step10 : compute the sum of c with d*10 and store it in e
Step11 : print the value of variable c
Step12 : End of the program.

FLOW CHART :
Start

Read a,b

compute c = (b%10)*a

d=(b/10)*a

Print c,d

Compute
e = c+(d*10)

Print e

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 57


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM :
// c program on multipication of two numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e;
clrscr();
printf("\nenter a b values : ");
scanf("%d%d",&a,&b);
printf("\n-----MULTIPLICATION OF TWO NUMBERS-----");
printf("\n\n\t %d\n\tx%d",a,b);
c=(b%10)*a;
d=(b/10)*a;
printf("\n--------------");
printf("\n%d * %d = %d",b%10,a,c);
printf("\n%d * %d = %d",b/10,a,d);
printf("\n--------------");
printf("\nAddition= %d",c+(d*10));
printf("\n--------------");
getch();
}

OUTPUT :

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 58


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to print swaping 3 numbers.

PROCEDURE:

ALGORITHM:

Step 1: Start the program.

Step 2: Read a, b, c

Step 3: Display before swap values a, b, c

Step 4: a =a+(b+c)

Step 5: b = a-(b+c)

Step 6: c = a-(b+c)

Step 7: a =a-(b+c)

Step 8: Display after swap values a, b, c

Step 9: Stop the program.

FLOWCHART:

Start

Read a,b,c

compute
a=a+b+c,
b=a-(b+c),
c=a-(b+c),
a=a-(b+c)

Print a,b,c

Stop

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 59


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:-

#include<stdio.h>

#include<conio.h>

void main()

int a,b,c;

clrscr();

printf("Enter value of a,b,c:");

scanf("%d%d%d",&a,&b,&c);

printf("Before swapping:- \na=%d\nb=%d\nc=%d",a,b,c);

a=a+b+c;

b=a-(b+c);

c=a-(b+c);

a=a-(b+c);

printf("\nAfter swapping:-");

printf("\na=%d\nb=%d\nc=%d",a,b,c);

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 60


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to print Reverse of a number.

PROCEDURE:

ALGORITHM:

Step 1: Declare the variables rev=0,i and num.

Step 2: Read the variable num.

Step 3: Store num%10 in the variable i.

Step 4: Store rev*10+I in the variable rev.

Step 5: Store num/10 in the variable num.

Step 6: Repeat the Steps three, four and five for another three times.

Step 7: End the program.

FLOWCHART:

start

Declare the variables rev, i and sum

Read variable num

i=num/10

rev=rev*10+i

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 61


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

NO
If rev=0

YES

Display rev

Stop

PROGRAM :

//C program to print reverse a number

#include<stdio.h>

#include<conio.h>

void main()

int rev=0,num,i;

clrscr();

printf("enter a number");

scanf("%d",&num);

i=num%10;

rev=rev*10+i;

num=num/10;

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 62


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

i=num%10;

rev=rev*10+i;

num=num/10;

i=num%10;

rev=rev*10+i;

num=num/10;

i=num%10;

rev=rev*10+i;

num=num/10;

printf("\nreverse of the number=%d",rev);

getch();

OUTPUT :

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 63


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM :Write a C program to check whether the given number is a Palindrome


or not a Palindrome.

PROCEDURE :

ALGORITHM :

STEP 1: Declare the variables rev=0,i and num.

STEP 2: Read the variablenum.

STEP 3: Store num in another variable a.

STEP 4: Store num%10 in the variable i.

STEP 5: Store rev*10+I in the variable rev.

STEP 6: Store num/10 in the variable num.

STEP 7: Repeat the steps three,four and five for another three times.

STEP 8: If variable a is equal to variable num then print “palindrome”

else print “not a palindrome”

STEP 9: End of the program.

FLOWCHART:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 64


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

print palindrome

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 65


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

//C program to check whether given number is palindrome or not a


palindrome.

#include<stdio.h>

#include<conio.h>

void main()

int rev=0,num,i,a;

clrscr();

printf("enter a four digit number");

scanf("%d",&num);

a=num;

i=num%10;

rev=rev*10+i;

num=num/10;

i=num%10;

rev=rev*10+i;

num=num/10;

i=num%10;

rev=rev*10+i;

num=num/10;

i=num%10;

rev=rev*10+i;

num=num/10;

a==rev?printf("\npalindrome"):printf("\nnot a palindrome");

getch();

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 66


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 67


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to check whether the number is an Armstrong or


not an Armstrong.

PROCEDURE:
ALGORITHM:

Step1: Start the program.

Step2: read a value.

Step3: Store a in g and Store (a%10) in b.

Step4: Store b*b*b*b in variable c.

Step5: Then divide a/10 and store the value in a.

Step6: Store (a%10) in b.

Step7: Store b*b*b*b in variable d.

Step8: Then divide a/10 and store the value in a.

Step9: Store (a%10) in b.

Step10: Store b*b*b*b in variable e.

Step11: Then divide a/10 and store the value in a.

Step12: Store (a%10) in b.

Step13: Store b*b*b*b in variable f.

Step14: Then divide a/10 and store the value in a.

Step15: Check if (c+d+e+f)==g.

Step16: If the above conditions are True, print g is Armstrong Number.

Step17: If the above conditions are False, print g is Not Armstrong

Number.

Step18: End of the program

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 68


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

FOWCHART:
Start

Declare a,
b,i=0,g=a values

Read a value

False True
Is i>3?

b=a%10sum+=b*b
*b*b

False True
g ==
sum

Print is not Armstrong Print Armstrong


Number Number

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 69


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

Program:

//Program to check whether a number is Armstrong or not Amstrong


#include<stdio.h>
#include<conio.h>
void main(){
int a,b,g,sum=0;clrscr();
printf("Enter a 4-digit Number: ");
scanf("%d",&a);g=a;
b=a%10;sum+=(b*b*b*b);a/=10;
b=a%10;sum+=(b*b*b*b);a/=10;
b=a%10;sum+=(b*b*b*b);a/=10;
b=a%10;sum+=(b*b*b*b);a/=10;
(g==sum)?printf("%d is Armstrong Number.\n",g):
printf("%d is not Armstrong Number.\n",g);
getch();
}
OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 70


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM:- write a C program to print the Size of papers.

PROCEDURE:-

ALGORITHM:-

Step-1:-Read the numbers aoht= 1189, aowd= 841.

Step-2 :- print a0ht*a0wd.

Step-3:- compute a0ht/2 and store in a1wd and store a0wd in a1ht.

Step-4:- print a1ht*a1wd.

Step-5:- compute a1ht/2 and store in a2wd and store a1wd in a2ht.

Step-6:-print a2ht*a2wd.

Step-7:- compute a2ht/2 and store in a3wd and store a2wd in a3ht.

Step-8:-print a3ht*a3wd.

Step-9:- compute a3ht/2 and store in a4wd and store a3wd in a4ht.

Step-10:-print a4ht*a4wd.

Step-11:- compute a4ht/2 and store in a5wd and store a4wd in a5ht.

Step-12:- print a5ht*a5wd.

Step-13:- compute a5ht/2 and store in a6wd and store a5wd in a6ht.

Step-14:-print a6ht*a6wd.

Step-15:- compute a6ht/2 and store in a7wd and store a6wd in a7ht.

Step-16:-print a7ht*a7wd.

Step-17:- compute a7ht/2 and store in a8wd and store a7wd in a8ht.

Step-18:- print a8ht*a8wd.

Step-19:- compute a8ht/2 and store in a9wd and store a8wd in a9ht.

Step-20:-print a9ht*a9wd.

Step-21:- compute a9ht/2 and store in a10wd and store a9wd in

a10ht.

Step-22:-print a10ht*a10wd.

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 71


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

Step-23:-End of the program.

PROGRAM:-

//C program on size of papers

#include<stdio.h>

#include<conio.h>

void main()

int a0ht=1189, a0wd=841 , a1ht , a2ht , a3ht , a4ht , a5ht , a6ht , a7ht ,
a8ht , a9ht , a10ht , a10wd , a1wd , a2wd , a3wd , a4wd , a5wd , a6wd ,
a7wd , a8wd , a9wd ;

clrscr();

printf("_________SIZE OF PAPERS_________\n");

printf("size of a0 paper=%dmm*%dmm\n",a0ht,a0wd,(a0ht*a0wd));

a1ht=a0wd,a1wd=a0ht/2;

printf("size of a1 paper=%dmm*%dmm\n",a1ht,a1wd,(a1ht*a1wd));

a2ht=a1wd,a2wd=a1ht/2;

printf("size of a2 paper=%dmm*%dmm\n",a2ht,a2wd,(a2ht*a2wd));

a3ht=a2wd,a3wd=a2ht/2;

printf("size of a3 paper=%dmm*%dmm\n",a3ht,a3wd,(a3ht*a3wd));

a4ht=a3wd,a4wd=a3ht/2;

printf("size of a4 paper=%dmm*%dmm\n",a4ht,a4wd,(a4ht*a4wd));

a5ht=a4wd,a5wd=a4ht/2;

printf("size of a5 paper=%dmm*%dmm\n",a5ht,a5wd,(a5ht*a5wd));

a6ht=a5wd,a6wd=a5ht/2;

printf("size of a6 paper=%dmm*%dmm\n",a6ht,a6wd,(a6ht*a6wd));

a7ht=a6wd,a7wd=a6ht/2;

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 72


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

printf("size of a7 paper=%dmm*%dmm\n",a7ht,a7wd,(a7ht*a7wd));

a8ht=a7wd,a8wd=a7ht/2;

printf("size of a8 paper=%dmm*%dmm\n",a8ht,a8wd,(a8ht*a8wd));

a9ht=a8wd,a9wd=a8ht/2;

printf("size of a9 paper=%dmm*%dmm\n",a9ht,a9wd,(a9ht*a9wd));

a10ht=a9wd,a10wd=a9ht/2;

printf("size of a10 paper=%dmm*%dmm\n",a10ht,a10wd,(a10ht*a10wd));

printf("_______________________________");

getch();

OUTPUT :-

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 73


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to find the number of notes that will combine to
give Rs Note.

PROCEDURE:

ALGORITHM:

Step1: Start of the program.

Step2: Declare and Read the variables Amount, Hundred, Fifty, Twenty,

Ten, Five, One.

Step3: Divide amount /hundred store the value in Hundred.

Step4: Do modulus amount% hundred store the value in Amount.

Step5: Divide amount/fifty store the value in Fifty.

Step6: Do modulus amount% fifty store the value in Amount.

Step7: Divide amount/ twenty store the value in Twenty.

Step8: Do modulus amount %wenty store the value in Amount.

Step9: Divide amount/ ten store the value in ten.

Step10: Do modulus amount% ten store the value in Amount.

Step11: Divide amount/ five store the value in five.

Step12: Do modulus amount %five store the value in Amount.

Step13: Divide amount/one store the value in one.

Step14: Print Hundred, Fifty, Twenty, Ten, Five, One

Step15: End of the program.

FLOWCHART:

Start

Read amount

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 74


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

Compute

Hundred=Amount/100,

Amount=Amount%100,

Fifty=Amount/50,

Amount=Amount%50,

Twenty=Amount/20,

Amount=Amount%20,

Ten=Amount/10,

Amount=Amount%10,

Five=Amount/5,

Amount=Amount%5,

One=Amount/1,

Amount=Amount%1

Print Hundred,Fifty,twenty,Ten,Five,One

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 75


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

/*c program to find the number of notes that will

combine to give Rs N*/

#include<stdio.h>

#include<conio.h>

void main()

int Amount,Hundred,Fifty,Twenty,Ten,Five,One;

clrscr();

printf("Enter the Amount=");

scanf("%d",&Amount);

Hundred=Amount/100;

Amount=Amount%100;

Fifty=Amount/50;

Amount=Amount%50;

Twenty=Amount/20;

Amount=Amount%20;

Ten=Amount/10;

Amount=Amount%10;

Five=Amount/5;

Amount=Amount%5;

One=Amount/1;

Amount=Amount%1;

printf("\n Hundred =%d notes\n Fifty =%d notes\n Twenty =%d notes

\n Ten =%d notes \n Five =%d notes\n One =%d notes",

Hundred, Fifty, Twenty, Ten, Five, One);

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 76


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 77


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to print the Salary pay slip.

PROCEDURE:

ALGORITHM:

Step1: Start of the program.

Step2: Declare and Read the id, basic, hra, da, mtechinc, tsinc, total1,

total2, gis, ptax, cps, inc.

Step3: Enter the Emp id and Enter the basic amount.

Step4: (basic*27)/100 store this value in hra.

Step5: (basic*38)/100 store this value in da.

Step6: (basic*0.5)/100 store this value in mtechinc.

Step7: (basic*0.12)/100 store this value in tsinc.

Step8: (basic*0.02)/100 store this value in gis.

Step9: (basic*0.03)/100 store this value in ptax.

Step10: (basic+da)*0.1 store this value in cps.

Step11: (basic*1.5)/100 store this value in inc.

Step12:hra+da+mtechinc+tsincstrore this value in total1.

Step13:gis+ptax+cps+inc store this value in total2.

Step14: Print -------PAY SLIP ---------

Step15: Print EARNINGS deductions.

Step16: Print basic, gis, hra, pta, da, cps, mtechinc, inc, tsinc, total1,

total2, basic+total1,basic+total1-total2.

Step17: End of the program.

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 78


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

// C program to print salary pay slip.

#include<stdio.h>

#include<conio.h>

void main()

float id,basic,hra,da,mtechinc,tsinc,total1,total2,gis,ptax,cps,inc;

int a;

clrscr();

printf(" enter the emp id:");

scanf("%d",&id);

printf("\n enter the basic amount: ");

scanf("%f",&basic);

hra=(basic*27)/100;

da=(basic*38)/100;

mtechinc=(basic*0.5)/100;

tsinc=(basic*0.12)/100;

gis=(basic*0.02)/100;

ptax=(basic*0.03)/100;

cps=(basic+da)*0.1;

inc=(basic*1.5)/100;

total1=hra+da+mtechinc+tsinc;

total2=gis+ptax+cps+inc;

printf("\n -------PAY SLIP ---------");

printf("\n EARNINGS deductions\n");

printf("\n BASIC : %f ",basic); printf(" GIS : %f",gis);

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 79


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

printf("\n HRA : %f ",hra); printf("PTAX : %f",ptax);

printf("\n DA : %f ",da); printf("CPS : %f",cps);

printf("\n MTECHINC : %f ",mtechinc); printf(" INC : %f",inc);

printf("\n TSINC : %f ",tsinc);

printf("\n -----------------------------------------------------");

printf("\n total = %f ",total1); printf("total=%f",total2);

printf("\n GROSS SALARY =%f",basic+total1);

printf("\n NET SALARY =%f",basic+total1-total2);

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 80


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a c program to print SSC marks memo.

PROCEDURE:

ALGORITHM:

Step1: start of the program.

Step2: Declare and Read the variables eng, mat, phy, che, tel, hin, id
,total, per

Step3: Print student id and print ENGLISH, MATHS, PHYSICS,

CHEMISTRY, TELUGU, HINDI .

Step4: Print MARKS MEMO------ , SUB NAME , MARKS , GRADE

Step5:eng>80 if true print A if false go to eng>60 again if true print B if

false go to eng>40 if true print C if false go to eng>20 if true print D

if false print FAIL.

Step6: mat>80 if true print A if false go to mat>60 again if true print B if

false go to mat>40 if true print C if false go to mat>20 if true print D

if false print FAIL.

Step7:phy>80 if true print A if false go to phy>60 again if true print B if

false go to phy>40 if true print C if false go to phy>20 if true print D

if false print FAIL.

Step8:che>80 if true print A if false go to che>60 again if true print B if

false go to che>40 if true print C if false go to che>20 if true print D

if false print FAIL.

Step9:tel>80 if true print A if false go to tel>60 again if true print B if

false go to tel>40 if true print C if false go to tel>20 if true print D

if false print FAIL.

Step10:hin>80 if true print A if false go to hin>60 again if true print B if

false go to hin>40 if true print C if false go to hin>20 if true print D

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 81


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

if false print FAIL.

Step11: eng+mat+phy+che+tel+hin store this value in total

Step12: (total/6) store this value in per

Step13: Print total, per, per/10.

Step14: End of the program.

PROGRAM:

#include <stdio.h>

#include<conio.h>

void main()

int eng,mat,phy,che,tel,hin,id,total;

float per;

clrscr();

printf(" enter the student id : ");

scanf("%d",&id);

printf("\n enter the marks of ENGLISH :");

scanf("%d",&eng);

printf("\n enter the marks of MATHS :");

scanf("%d",&mat);

printf("\n enter the marks of PHYSICS :");

scanf("%d",&phy);

printf("\n enter the marks of CHEMISTRY :");

scanf("%d",&che);

printf("\n enter the marks of TELUGU :");

scanf("%d",&tel);

printf("\n enter the marks of HINDI :");

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 82


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

scanf("%d",&hin);

printf(" -------MARKS MEMO------\n");

printf(" SUB NAME MARKS GRADE \n");

printf("\n ENGLISH %d \t\t",eng); (eng>80?printf("A"): eng>60?

printf("B"): eng>40? printf("C"): eng>20? printf("D"): printf("FAIL"));

printf("\n MATHS %d \t\t",mat); (mat>80?printf("A"): mat>60?

printf("B"): mat>40? printf("C"): mat>20? printf("D"): printf("FAIL"));

printf("\n PHYSICS %d \t\t",phy); (phy>80?printf("A"): phy>60?

printf("B"): phy>40? printf("C"): phy>20? printf("D"): printf("FAIL"));

printf("\n CHEMISTRY %d \t\t",che); (che>80?printf("A"): che>60?

printf("B"): che>40? printf("C"): che>20? printf("D"): printf("FAIL"));

printf("\n TELUGU %d \t\t",tel); (tel>80?printf("A"): tel>60?

printf("B"): tel>40? printf("C"): tel>20? printf("D"): printf("FAIL"));

printf("\n HINDI %d \t\t",hin); (hin>80?printf("A"): hin>60?

printf("B"): hin>40? printf("C"): hin>20? printf("D"): printf("FAIL"));

total=eng+mat+phy+che+tel+hin;

per=(total/6);

printf("\n ------------------------");

printf("\n Total : %d",total);

printf("\n ------------------------");

printf("\n percentage :%.2f",per);

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 83


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

printf("\n CGPA :%.2f",per/10);

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 84


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to print Number of years, months, weeks, days in a

number.

PROCEDURE:

ALGORITHM:

Step1: Start of program.

Step2: Declare and Read num, years, months, weeks, days.

Step3: Print num.

Step4: Store years=num/365 and num=num%365 .

Step5: Store months=num/30 and num=num%30 .

Step6: Store weeks=num/7 and num=num%7 .

Step7: Store days=num .

Step8: print years, months, weeks, days .

Step9: End of the program

FLOWCHART:
Start

Declare num, years,


months, weeks, days

Read num

Compute

years=num/365,

num=num%365,

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 85


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

months=num/30,

num=num%30,

weeks=num/7,

num=num%7,

days=num

Print years,
months,weeks,

End

PROGRAM:

//C program on number of years, months, weeks, days.

#include<stdio.h>

#include<conio.h>

void main()

int num,years,months,weeks,days;

clrscr();

printf(" Enter num value=");

scanf("%d",&num);

years=num/365;

num=num%365;

months=num/30;

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 86


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

num=num%30;

weeks=num/7;

num=num%7;

days=num;

printf("\n YEARS=%d\n MONTHS=%d\n WEEKS=%d\n DAYS=%d",

years,months,weeks,days);

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 87


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: write a C program to check whether the given Alphabet is Vowel or


Consonant.

PROCEDURE:
ALGORITHM:

Step1: Start of the program.

Step2: declare and Read the variable x.

Step3: Enter x value in alphabet

Step4: (x==’a’, x==’e’, x==’i’, x==’o’, x==’u’, x==’A’, x==’E’, x==’I’, x==’O’,

x==’U’) If true print Vowel. If false print Consonant.

Step5: Print x value.

Step6: End of the program.

FLOWCHART:
Start

Declare x variable

Read x variable

((x==’a’)||(x==’e’)||(x=
=’i’)||(x==’o’)||(x==’u’)
Yes ||(x==’A’)||(x==’E’)||( No
x==’I’)||(x==’O
’)||(x==’U ’))

Print Vowel Print

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 88


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

End

PROGRAM:

//C program to check the alphabet is vowel or consonant.

#include<stdio.h>

#include<conio.h>

void main()

char x;

clrscr();

printf(“Enter the x value=”);

scanf(“%c”,&x);

((x==’a’)||(x==’e’)||(x==’i’)||(x==’o’)||(x==’u’)||(x==’A ’)||(x==’E ’)||(x==’I’

)||(x==’O ’)||(x==’U ’))?printf(“Vowel”):printf(“Consonant”);

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 89


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C programto check whether the given Character is a Digit or

an Alphabet or a Special symbol.

PROCEDURE:

ALGORITHM:

Step1: Start the program.

Step2: Read the character p.

Step3: Apply the condition (p>=’a’)and(p<=’z’)or (p>=’A’)and(p<=’Z’).

Step4: If true print character.

Step5: If false activated condition is (p>=’0’) and (a<=’9’).

Step6: If true print a digit.

Step7: If false, print special symbol.

Step8: End program.

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 90


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

FLOWCHART:
Start

Read the
character p

False
True (p>=’a’)&&(p<=’
z’)||(p>=’A’)&&
p(<=’Z’)

print character True False


P<=’0’&&
p>==’9’)

Print digit
Print symbol

Stop

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 91


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

/* C program on to check whether given character is a digit or alphabet or

Special symbol*/

#include<stdio.h>

#include<conio.h>

void main()

char p;

clrscr();

printf(“enter p value=”);

scanf(“%c”,&p);

((p>=’a’)&&(p<=’z’)||(p>=’A’)&&(p<=’Z’)?printf(“%c is an alphabet”,c):(p>=’0’)
&&(p<=’9’)?printf(“%c is a digit”,p):printf(“%c is a special symbol”,p);

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 92


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C Program to print using all data types of C.

PROCEDURE:

ALGORITHM:

Step1: Declare the variable “A” to integer “A1” variable to a short integer

“A2”Variable to long integer .And A3 to long long integer,

Step2: Now Read the value of A1 from keyboard

Step3: Declare A1 value to 127

Step4: Declare A2 value to max value i.e. 2,147,483,648.

Step5: Declare A3 value to the value -2,147,483,900.

Step5: Declare A4 value to unsigned long long int and assign it to

2,147,483,900

Step6: Declare the variable “B” to float “B1” variable to a double and

“B2” variable to Long double

Step7: Now Read the value of “B” from keyboard

Step8: Assign B1 value to 22/7.

Step9: And also Assign B2 value to 22/7.

Step10: Declare C1 variable as unsigned short integer and put the value

of C1to 255.

Step11: Declare C2 variable as unsigned integer and assign the value of

C2 to 65000

Step12: Declare C3variable as unsigned long integer and assign the

value of C3 to 34*100000000.

Step13: Declare D1 variable to character and assign it to ‘c’.

Step14: Declare D2 variable to unsigned character and assign it to 255.

Step15: Now print all the variables.

Step16: End of the program.

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 93


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

#include<stdio.h>

#include<conio.h>

void main ()

int A;

short int A1=1276;

long int A2 = 2147483648;

unsigned short int C1=255;

unsigned int C2=65000;

unsigned long int C3=3*10000;

long long int A3=-2147483900;

float B;

double B1=(double)22/7;

long double B2=(long double)22/7;

char D1='c';

unsigned char D2=200;

unsigned long long int A4=2147483900;

clrscr();

printf("Enter any two values");

scanf("%d %f",&A,&B);

printf("int = %d\nshort int=%hd\nlong int=%ld\nunsigned short


int=%hu\nunsigned int=%u\nunsigned long int=%lu\nlong long
int=%lld\nfloat=%f\ndouble=%lf\nlong
double=%Lf\ncharecter=%c\nunsignedcharecter=%c\n unsigned long long
int=%llu",A,A1,A2,C1,C2,C3,A3,B,B1,B2,D1,D2,A4);

getch(); }

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 94


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 95


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM : Write a C program to print using Implicit and Explicit typecasting.

PROCEDURE:

ALGORITHM :

IMPLICIT TYPE CASTING

STEP:1 Start program

STEP:2 Declare the variables character c, unsigned character uc, short

integer hd, long integer lu, unsigned long long integer llu, float

f, double d, long double ld and integer I,

STEP:3 Read the value of I .

STEP:4 Declare llu=lu=lf=c=uc=hd=f=d=ld=i

STEP:5 Print the values of llu,lu,lf,c,uc,hd,I,f,d,ld

STEP:6 End the program.

EXPLICIT TYPE CASTING

STEP 1: Start of the program.

STEP 2: Declare int a,b.

STEP 3: Declare short int c, long int d, long long int e, float f, double g,

long double h, char I.

STEP 4: Assign a+b expression with the data type short int using explicit

technique.

STEP 5: Assign a+b expression with the data type long int using explicit

technique.

STEP 6: Assign a+b expression with the data type long long int using

explicit technique.

STEP 7: Assign a+b expression with the data type float using explicit

technique.

STEP 8: Assign a+b expression with the data type double using explicit

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 96


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

technique.

STEP 9: Assign a+b expression with the data type long double using

explicit technique.

STEP 10: Assign a+b expression with the data type char using explicit

technique.

STEP 11: End of the program.

IMPLICIT TYPE CASTING

PROGRAM:

//Program on Implicit on all Datatypes.

#include<stdio.h>

#include<conio.h>

void main(){

int i;charc;unsigned char uc;signed char sc;short int hd;long int ld;

long long int lld;floatf;doublelf;long double Lf;unsigned long int lu;

unsigned long long int llu;clrscr();

llu=lu=Lf=lf=f=lld=ld=hd=sc=uc=c=i;

printf("Enter a Number: ");

scanf("%d",&i);

llu=lu=Lf=lf=f=lld=ld=hd=sc=uc=c=i;

printf("char = %c \n",c);

printf("unsigned char = %c \n",uc);

printf("signed char = %c \n",sc);

printf("short int = %hd \n",hd);

printf("long int = %ld \n",ld);

printf("long long int = %lld \n",lld);

printf("float = %f \n",f);

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 97


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

printf("double = %lf \n",lf);

printf("long double = %Lf \n",Lf);

printf("unsigned long int = %lu \n",lu);

printf("unsigned long long int = %llu \n",llu);

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 98


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

EXPLICIT TYPE CASTING

PROGRAM:

//Program on Explicit typecasting in all Datatypes.

#include<stdio.h>

#include<conio.h>

void main(){

int a,b;

clrscr();

printf("Enter a Number: ");

scanf("%d %d",&a,&b);

printf("char = %c \n",(char)a+b);

printf("unsigned char = %c \n",(unsigned char) a+b);

printf("signed char = %c \n",(signed char) a+b);

printf("short int = %hd \n",(short int) a+b);

printf("long int = %ld \n",(long int) a+b);

printf("long long int = %lld \n",(long long int) a+b);

printf("float = %f \n",(float) a+b);

printf("double = %lf \n",(double) a+b);

printf("long double = %Lf \n",(long double) a+b);

printf("unsigned long int = %lu \n",(unsigned long int) a+b);

printf("unsigned long long int = %llu \n",(unsigned long long int) a+b);

getch();

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 99


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 100


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to enter a name and display name using an Array.
PROCEDURE:

ALGORITHM:

Step1: start of the program.

Step2: read name[50].

Step3: store name into name[50] array.

Step4: print the name.

Step5: End of the Program

FLOWCHART:

Start

Declare name[50]
variable

Read
name[50]

Print
name[50]

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 101


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

//Program on Entering and printing String.


#include<stdio.h>
#include<conio.h>
void main(){
char name[50];clrscr();
printf("Enter your name: ");
scanf("%s",name);
printf("Your Name is %s",name);
getch();
}
OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 102


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to print using Preproccesor directives.

PROCEDURE:

ALGORITHM:

Step1: Start of the program.

Step2: Define a Pre-processor directive Macro function Max (a, b) to


return greatest among a, b, c inputs.

Step3: Define another Pre-processor directive with macro name ‘mohd’


giving value 60.

Step4: Define another Pre-processor directive with macro name ‘subhan’


giving value 121.

Step5: A pre-processor directive if subhan is equal to


121undefinedsubhan macro.

Step6: A pre-processor directive if math.h is included through an error


“include the header file”

Step7: A pre-processor directive if subhan is defined error “logic error”.

Step8: Declare variablea,b,c.

Step8:A pre-processor directive if mohd defined then print pin no 60 is


present else print pin no 60 is absent.

Step9:A pre-processor if tv price is greater than 20000, else if tv price is


less than or equal to 3000 print tv price is too low, else print tv price is in
budget.

Step10: Read the values of the variables a, b, c.

Step11: Using macro function to replace ((a>b&&a>c)?a:b>c&&b>a)?b:c)


with Max(a,b,c)

Print the greatest of the three inputs a, b, c.

Step12: End of the program.

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 103


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

#include<stdio.h>

#include<conio.h>

#include<math.h>

#define Max(a,b,c) ((a>b&&a>c)?a:(b>c&&b>a)?b:c)

#definemohd 60

#definesubhan 121

#defineTvprice 20000

#if(subhan==121)

#undefsubhan

#endif

void main(){

int a,b,c,d;

clrscr();

#ifndef __MATH_H

#error include the header file

#endif

#ifdefsubhan

#error logic error

#endif

#ifdefmohd

printf("pinno.%d is present",mohd);

#else

printf("pinno.%d is absent",mohd);

#endif

#if(Tvprice>20000)

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 104


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

printf("\ntv price is too high");

#elif(Tvprice<=3000)

printf("\ntv price is too low(need standard one)")

#else

printf("\ntv price is in budget");

#endif

printf("\nenter three numbers");

scanf("%d%d%d",&a,&b,&c);

printf("%d is greater among %d %d %d",Max(a,b,c),a,b,c);

getch();

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 105


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to print using Math.h headerfile.

PROCEDURE:

ALGORITHM:
Step1: start the program.

Step2: read a value.

Step3: Then print sqrt function using a value.

Step4: Then print pow function using a value.

Step5: Then print log function using a value.

Step6: Then print log10 function using a value.

Step7: Then print fabs function using a value.

Step8: Then print exp function using a value.

Step9: Then print ceil function using a value.

Step10: Then print floor function using a value.

Step11: Then printf mod function using a value.

Step12: Then print sin of a.

Step13: Then print cos of a.

Step14: Then print tan of a.

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 106


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

FLOWCHART:

Start

Declare a value

Read a
value

print sqrt function, print pow function, print log


function, print log10 function, print fabs function,
print exp function, print ceil function, print floor
function, print mod function, print sin, print cos,
print tan.

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 107


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:
//Program on math.h header file.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main(){
float a;clrscr();
printf("------Using Math.h Header File------\n");printf("\n");
printf("Enter a number: ");
scanf("%f",&a);
printf("sqrt(%.2f) = %.2f \n",a,sqrt(a));
printf("pow(%.2f,2.00) = %.2f \n",a,pow(a,2.0));
printf("log(%.2f) = %.2f \n",a,log(a));
printf("log10 = %.2f \n",log10(a));
printf("fabs(%.2f) = %.2f \n",a,fabs(a));
printf("exp = %.2f \n",exp(a));
printf("ceil = %.2f \n",ceil(a));
printf("floor = %.2f \n",floor(a));
printf("fmod(%.2f,3.00) = %.2f \n",a,fmod(a,3.0));
printf("sin%.2f = %.2f\n",a,sin(a));
printf("cos%.2f = %.2f \n",a,cos(a));
printf("tan%.2f = %.2f \n",a,tan(a));
getch();
}

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 108


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 109


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

AIM: Write a C program to print using Input and Output Functions.


PROCEDURE:

ALGORITHM:

Step1: Start the program.

Step2: read character a, name[50].

Step3: print the value of a using getchar().

Step4: Then, store the Name in name[50].

Step5: print name[50] using gets function.

Step6: Then, again store any string in name[50].

Step7: Then, print the string using printf().

Step8: Add some decorators in the program.

Step9: End of the Program

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 110


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

FLOWCHART:
Start

Declare a,
name[50] ;

Read name[50]
using gets

printname[50]
using puts

Read a value

Print a value

read name[50]

Print name[50]

End

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 111


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

PROGRAM:

//Program on Input and Output Functions.


#include<stdio.h>
#include<conio.h>
void main(){
char a,name[50]; clrscr();
printf("___Using gets and puts___\n");
printf("Enter Your Name: ");
gets(name);
printf("Your name is ");
puts(name);
printf("___Using getchar and putchar___\n");
printf("Enter a character: ");
a=getchar();
printf("Entered Character is : ");
putchar(a);
printf("___Using printf and scanf___\n");
printf("Enter a String: ");
scanf("%s",name);
printf("Entered String is %s \n",name);
getch();
}

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 112


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech
SUBJECT TITLE: PROGRAMING IN C LAB BRANCH: DCSE
SUBJECT CODE: CS-210 SEM: SECOND SEM

OUTPUT:

PIN NO:22001-CS- 071 NAME: C.GANESH DATTA PAGE NO: 113


SUBJECT EXPERT: R.BHARAT KUMAR M.Tech

You might also like