Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

Assignment No: 4

Name: Ingawale Shri Kisan Date:


Class: BCA- I Roll No: 38

Q. write C program to compute grade of student using else if ladder

The grades are assigned as follows:

Marks Grade
Marks<40 Fail
Mark>=40 & Pass
mark<60
Mark>=60 & 1st class
mark<75
Mark>=75 & distinction
mark<=100
Algorithm:

Step1: start

Step2: input mark

Step3: get input from user and store it

Step4: if marks are Marks<40 then display fail else if Mark>=40 & mark<60

Display pass

Else if Mark>=60 & mark<75 display 1st class else if Mark>=75 &

mark<=100 display distinction


Step5: print out put

Step 6: stop

Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int marks ;
printf("enter your grade");
scanf("%d",&marks);
if( marks<40) {
printf("fail");

}
else if(marks>=40 && marks<60){
printf("pass");
}

else if(marks>=60 && marks<75){


printf("1st class");
}

else if(marks>=75 && marks<=100){


printf("distingtion");
}
getch();
}
Output:
Assignment No: 5

Name: Ingawale Shri Kisan Date :


Class: BCA- I Roll No: 38

Q. write C program to check whether the entered year is leap or not


(Year is leap if divisible by 4, 100,400)

Algorithm:

Step1: start

Step2: input year

Step3: get input from user and store it

Step4: if marks are Marks<40 then display fail else if Mark>=40 & mark<60

Display pass

Else if Mark>=60 & mark<75 display 1st class else if Mark>=75 &

Mark<=100 display distinction

Step5: print out put

Step 6: stop

Code:
#include<stdio.h>
#include<conio.h>
void main ()
{
int year;
printf("enter year to check");
scanf("%d",&year);
if(year%400==0){
printf("entered year is leap");
}
else if (year%100==0){
printf("entered year is not leap");
}
else if (year%4==0){
printf("entered year is leap");
}
else{
printf("entered year is not leap");
}
getch();
}

Output :
Assignment No: 6

Name: Ingawale Shri Kisan Date :


Class: BCA- I Roll No: 38

Q write a c program to check whether no is Armstrong or not

Algorithm:
Step 1: start
Step2:take input as a, r, sum,x

Step3:divide a by 10 and save reminder in r


Step4:
Step5:

Flowchart:
Code:
#include<stdio.h> 
#include<conio.h>  
 
 void main()    
{    
int  n,r,sum=0,temp;    
printf("enter the number=");    
scanf("%d",&n);    
temp=n;    
while(n>0)    
{    
r=n%10;    
sum=sum+(r*r*r);    
n=n/10;    
}    
if(temp==sum)    
printf("armstrong  number ");    
else    
printf("not armstrong number");    
}   

Output:
Assignment No: 7

Name: Ingawale Shri Kisan Date:


Class: BCA- I Roll No: 38
Q write a c program to perform arithmetic operation using switch statement

1 addition
2substraction
3multiplication
4divition

Algorithm:
step1:start
Step2:input a,b,c
Step3:take input for a,b
Step4:use switch for assigning function to perticuler number
As follow 1 for addition 2 for substraction ,3 for multiplication,4 for divition
Step5: print output
Step6:stop:

Flowchart:

Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter number");
scanf("%d",&a);
printf("enter number");
scanf("%d",&b);
printf("type 1 to add ,2 to sub ,3 to multiply ,4 to divide");
scanf("%d",&c);
switch(c){
case 1 :
printf("addition of %d and %d is:%d",a,b,a+b );
break ;
case 2 :
printf("subtraction of %d and %d is:%d",a,b,a-b );
break ;
case 3 :
printf("multiplication of %d and %d is:%d",a,b,a*b );
break ;
case 4 :
printf("divition of %d and %d is:%d",a,b,a/b );
break ;
default :
printf("plz enter valid numbeer" );

getch();
}

Output:
Assignment No: 8

Name: Ingawale Shri Kisan Date :


Class: BCA- I Roll No: 38

Q. write a c Program to perform week days using switch statement


Note . use 7days in switch case

Algorithm :
Step 1: Start
Step 2 : Input a
Step 3: Now use switch statement and compare the a with numbers in 1
to 7 As 0 to Sunday, I to Monday, 2 to Tuesday, 3 to Wednesday, 4
Thursday, 5 Saturday.
Step 4: print output
Step 5 : Stop
Code:
#include <stdio.h>
#include <conio.h>

void main()
{
int a;
clrscr();
printf("Enter number ");
scanf("%d",&a);
switch(a){
case 0 :
printf("sunday");
break;
case 1 :
printf("monday");
break;
case 2 :
printf("tuesday");
break;
case 3 :
printf("wednesday");
break;
case 4 :
printf("thursday");
break;
case 5 :
printf("friday");
break;
case 6 :
printf("satarday");
break;
}
getch();
}

Output

You might also like