Vous êtes sur la page 1sur 6

## ROLL NO: Z-12

MS BATCH-24
SUBJECT : COMPUTER SKILLS (CC-04)
ASSIGNMENT 02

QUESTION 01
#include<stdio.h>
#include<conio.h>
int main (void)
{
clrscr();
int x=0;
char ch;
printf("Enter the phrase and press enter when done\n");
do
{
ch=getche();
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
x++;
else if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
x++;
}
while(ch!='\r');
printf("\n Number of vowels in line: %d",x);
getch();
}

QUESTION 02
#include<conio.h>
#include<stdio.h>
void main (void)
{
clrscr();
int a,b,count=0,sum=0;
float count1=0,average=0;
printf("All prime # b/w 0 and 100 are:\n");
for(a=1;a<=100;a++)
{
for(b=1;b<=a;b++)
{
if(a%b==0)
count++; }
if(count==2)
{ printf("%d ",a);
sum+=a;
count1++;}
count=0;
}
average=sum/count1;
printf("\n\n average = %f",average);
getch();
}

QUESTION 03
#include<conio.h>
#include<stdio.h>
void main (void)
{
clrscr();
int a,b,start,end;
printf("Enter the range of numbers\n eg 1-100\n\n");
scanf("%d-%d",&start,&end);
printf("\nEven number btw %d and %d are\n",start,end);
for (a=start;a<=end;++a)
{
if (a%2!=0)
continue;
printf("%d ",a);
}
getch();
}

QUESTION 04
#include<stdio.h>
#include<conio.h>
void main (void)
{
clrscr();
char input;
printf("Enter the Profession of Student\n");
printf("Enter C for Chemist\n D for Doctor\n");
printf(" E for Engineer\n M for Mathematician\n");
printf(" P for Physicist\n");
scanf("%c",&input);
if(input=='c'||input=='d'||input=='C'||input=='D')
printf("Congratulation you have been admitted to MS Nuclear Medicine\n");
else if(input=='m'||input=='p'||input=='M'||input=='P')
printf("Congratulation you have been admitted to MS Nuclear Engineering\n");
else if(input=='e'||input=='E')
printf("Congratulation you have been admitted to MS System Engineeering\n");
else
printf("Invalid Input\n");
getch();
}

QUESTION 05
#include<stdio.h>
#include<conio.h>
void main (void)
{
float n;
clrscr();
printf("enter Richter scale number to show its characterization\n");
scanf("%f",&n);
if(n<5)
printf("little or no damage");
else if(n<5.5)
printf("some damage");
else if(n<6.5)
printf("seroius damage:walls may crack or fall");
else if(n<7.5)
printf("Disaster:houses and building may collapse:");
else
printf("Catastrophe:most building destroyed");
getch();
}

QUESTION 06

#include<stdio.h>
#include<conio.h>
#define pi 3.1416
void circle(void);
void rectangle(void);
void square(void);
void sphere(void);
void triangle(void);
void main(void)
{
clrscr();
int check;
printf("Select the desired shape\n");
printf("press 1 for Cirle\n 2 for Square\n");
printf(" 3 for Sphere\n 4 for Rectangle\n");
printf(" 5 for triangle\n");
scanf("%d",&check);
if(check==1)
circle();
else if (check==2)
square();
else if (check==3)
sphere();
else if (check==4)
rectangle();
else if (check==5)
triangle();
else
printf("Invalid Selection");
getch();
}
void circle(void)
{
float r;
scanf("%f",&r);
printf("Area of circle = %f",(pi*r*r));
}
void square(void)
{
int side;
printf("Enter the side of Square\n");
scanf("%d",&side);
printf("Area of square = %d",(side*side));
}
void sphere(void)
{
float r;
scanf("%f",&r);
printf("Area of Sphere = %f",(4*pi*r*r));
}
void rectangle(void)
{
int length,width;
printf("Enter the length of rectangle\n");
scanf("%d",&length);
printf("Enter the width of rectangle\n");
scanf("%d",&width);
printf("Area of rectangle = %d",(length*width));
}
void triangle(void)
{
int base,height;
printf("Enter the base of triangle\n");
scanf("%d",&base);
printf("Enter the height of triangle\n");
scanf("%d",&height);
printf("Area of triangle = %d",(base*height)/2);
}

QUESTION 07
#include<conio.h>
#include<stdio.h>
void main (void)
{
clrscr();
int a,b,c,inner=1;
printf("\n\n\n");
for(a=5;a>=1;a--)
{
printf("\t\t");
for(b=5;b>=a;b--)
printf("\b");
for(c=5;c>=a;c--)
printf("%d ",inner);
printf("\n");
inner++;
}
getch();
}
QUESTION 08

#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
char a,b,c,d,e;
char ch,ch1;
ch='A';
ch1='A';
e='J';
for (a='H';a>='A';----a)
{
for (b='H';b>=a;----b)
{
printf("%c ",ch);
++++ch;
}
for(d='A';d<=e;++d)
printf(" ");
----e;
for(c='H';c>=a;----c)
{
printf("%c",ch1);
printf("\b\b\b");
++++ch1;
}
printf("\n");
}
getch();
}