Escolar Documentos
Profissional Documentos
Cultura Documentos
(ECS-151)
1
COMAPUTER PROGRAMMING LAB. (ECS-151)
EXPERIMENT – 1
Objective: To give the knowledge of basic DOS commands to
the students & use of DOS editor.
Theory & concepts:
Basically the purpose of the operating system is to interact with
user and control the various operations of the devices. Operating
system is software, which gives control to the user to do the
desired.
In operating system category first you will Microsoft disk
operating system. It is single user and single tasking operating
system.
DOS is command-based operating system. You just type the
command and press the enter key then the command will execute.
e.g. in question 1 some commands are given. For executing the
command type the command on the command prompt and by
pressing the enter key the command will execute.
In question 1 for executing the DATE command, first type the
date and press enter key, and the current date will be shown on
screen.
By DIR command user can see the directories present in the hard
disk.
2
COMAPUTER PROGRAMMING LAB. (ECS-151)
RGEC CS
IT
ME
EE
EC
3
COMAPUTER PROGRAMMING LAB. (ECS-151)
3. Create a file “abc.txt” using copy con command and then make
modifications in file using MS-DOS Editor.
EXPERIMENT – 2
External commands not require certain special DOS file for being
executed.
4
COMAPUTER PROGRAMMING LAB. (ECS-151)
• MD
• CD
• RD
• CLS
• DIR
• DATE
• TIME
• COPY CON
• TYPE
• TREE
• COPY
• DOSKEY
• PATH
• REM
• DEL
• CHKDSK
• FORMAT
• DISKCOPY
• MORE
• FDISK
• PROMPT
5
COMAPUTER PROGRAMMING LAB. (ECS-151)
• SORT
• FIND
• ATTRIB
• XCOPY
• MEM
EXPERIMENT – 3
6
COMAPUTER PROGRAMMING LAB. (ECS-151)
7
COMAPUTER PROGRAMMING LAB. (ECS-151)
EXPERIMENT – 4
2. In paint
Draw the map of India with state distribution (color).
Map of UP with district distribution (color).
3. In Ms-PowerPoint
Make a presentation on the topic role of computer in village
Make a presentation on any topic of your choice.
4. Define the topic
Internet
Internet browser
Search engine
5. Using google.com search engine, search jobs sites of India.
6. Make a E-mail account in rediffmail.com
8
COMAPUTER PROGRAMMING LAB. (ECS-151)
9
COMAPUTER PROGRAMMING LAB. (ECS-151)
EXPERIMENT – 5
10
COMAPUTER PROGRAMMING LAB. (ECS-151)
11
COMAPUTER PROGRAMMING LAB. (ECS-151)
Experiment –6
Q-2) WAP to print the ODD, 12.00, 12.43, 12, c, a using the
constants.
12
COMAPUTER PROGRAMMING LAB. (ECS-151)
13
COMAPUTER PROGRAMMING LAB. (ECS-151)
EXPERIMENT – 7
#include<stdio.h>
main()
{
int a;
scanf(“%d”,&a);
if (a==1)
printf(“Yes”);
else
printf(“No”);
}
Switch: Switch ststement is a multiway decisions that tests
whethere an expression matches of a number of constant integer
values and branches accordingly.
e.g.
switch (expression)
{
case const expr : ststement
case const expr : ststement
default : statements
}
14
COMAPUTER PROGRAMMING LAB. (ECS-151)
float u,v,a,t,s;
clrscr();
printf("\n Enter three Newton's Laws of motion");
printf("\n 1. v=u+a*t \n 2. s=u*t+(1/2)*a*t*t \n 3.
v*v=u*u+2*a*s");
printf("\n Enter Equation No. you want to use:");
scanf("%d",&n);
switch(n)
{
case 1:
printf("Enter the value of initial velocity(u), accelaration(a),
and time(t)");
scanf("%f%f%f",&u,&a,&t);
v=u+a*t;
printf("\n The final velocity is v=%f",v);
break;
case 2:
Loops-
Loops are used to execute a particular ststement, instruction more
than one time then loops are used. Loops are for, while , do while
loop.
for loop-
for(initialize counter; test counter; increment counter)
{
do this;
15
COMAPUTER PROGRAMMING LAB. (ECS-151)
and this;
and this;
}
e.g. to print any statement five times then loop will be like that
for (i=0; i<=4; i++)
{
printf(“RGEC”);
}
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int qty;
float rate,tot;
float dis=0.0;
printf("Enter quantity purchased and rate");
scanf("%d%f",&qty,&rate);
if(qty>100)
dis=0.1;
tot=(qty*rate)-(qty*rate*dis);
printf(" The total expense is %f",tot);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
16
COMAPUTER PROGRAMMING LAB. (ECS-151)
int cy,yoj,bs,yos,bonus;
float da,hra,gs;
clrscr();
printf("\n Enter current year and year of joining and basic salary");
scanf("%d%d%d",&cy,&yoj,&bs);
yos=cy-yoj;
if(yos>3)
{
bonus=2500;
} else {
bonus=0;
}
if(bs<1500)
{
da=(0.9)*bs;
hra=(0.1)*bs;
} else{
da=(0.98)*bs;
hra=500.0;
}
gs=bs+da+hra+bonus;
printf("\n Gross Salary is %f",gs);
getch();
}
17
COMAPUTER PROGRAMMING LAB. (ECS-151)
} else
{
printf("\n The largest number is %d",b);
}
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int m1,m2,m3,m4,m5,tot;
float per;
clrscr();
printf("\n Enter the marks of the student in five subjects:");
scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);
tot=m1+m2+m3+m4+m5;
per=tot/5;
if(per>=75)
printf("\n The result is Honours");
else{
if(per>=60)
printf("\n the result is First Division");
else{
if(per>=50 || per<60)
18
COMAPUTER PROGRAMMING LAB. (ECS-151)
A–Z 65-90
a–z 97-122
-0 – 9 48-57
Special symbols 0-47, 58-64, 91-96, 123-127
EXPERIMENT – 8
#include<stdio.h>
#include<conio.h>
19
COMAPUTER PROGRAMMING LAB. (ECS-151)
void main()
{
int x,y;
clrscr();
printf("\n Enter the inputs of the Gate");
scanf("%d%d",&x,&y);
if(x==0 || y==0)
printf("\n The output is 0");
else
printf("\n The output is 1");
getch();
}
20
COMAPUTER PROGRAMMING LAB. (ECS-151)
Q-1) WAP to print the even number between 1 to 100 and also
print how many numbers are even.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,a=0;
clrscr();
for(i=1;i<=100;i++)
{
if(i%2==0)
{
printf("\t%d",i);
a=a+1;
}}
printf("\n Total even numbers are=%d",a);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
int fact=1;
clrscr();
printf("\n Enter the number whose factorial is required");
scanf("%d",&n);
if(n==0)
fact=1;
else
if(n==1)
fact=1;
else {
for(i=1;i<=n;i++)
{
fact=fact*i;
}}
printf("\n The required factorial is %d",fact);
getch();
}
21
COMAPUTER PROGRAMMING LAB. (ECS-151)
#include<stdio.h>
#include<conio.h>
void main()
{
int sum=0,n,r;
clrscr();
printf("\n Enter the number:");
scanf("%d",&n);
while(n!=0)
{
r=n%10;
n=n/10;
sum=sum+r;
}
printf("\n The sum of digits are %d",sum);
getch();
}
22
COMAPUTER PROGRAMMING LAB. (ECS-151)
#include<stdio.h> #include<stdio.h>
#include<conio.h> #include<conio.h>
void main() void main()
{ {
int i,j; int i,j;
clrscr(); clrscr();
for(i=1;i<=4;i++) for(i=1;i<=4;i++)
{ {
for(j=1;j<=i;j++) for(j=1;j<=i;j++)
{ {
printf("\t *"); printf("\t%d",j);
} }
printf("\n"); printf("\n");
} }
getch(); getch();
} }
23
COMAPUTER PROGRAMMING LAB. (ECS-151)
EXPERIMENT – 10
For
e.g. #include<stdio.h>
main()
{
char name[ ]=”RAM”;
int i=0;
while (i<=3)
{
printf(“%c”,name[i]);
i++;
}
24
COMAPUTER PROGRAMMING LAB. (ECS-151)
}
It prints RAM.
1) WAP to store 10 numbers in array and then print them.
2) WAP to find out sum of all elements of an array.
3) WAP to find the largest and second largest in the given array.
4) WAP to transpose of the given matrix.
5) WAP to multiply of two matrices and print the result.
6) WAP to input a string and print it.
7) WAP to count the length of the string. String is input by the
user.
8) WAP to count the numbers of vowels, consonants and spaces.
9) WAP to sort the string alphabetically.
10) WAP to check whether given string is palindrome or not.
25