0% found this document useful (0 votes)
11 views13 pages

Ayush Java 1

This document appears to be a Java assignment submitted by Ramani Ayush containing 13 coding problems and their outputs. Each problem demonstrates a different concept in Java like loops, conditional statements, functions etc. The problems get progressively more complex, starting with a basic while loop and ending with a program that takes marks as input and outputs the corresponding grade.

Uploaded by

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

Ayush Java 1

This document appears to be a Java assignment submitted by Ramani Ayush containing 13 coding problems and their outputs. Each problem demonstrates a different concept in Java like loops, conditional statements, functions etc. The problems get progressively more complex, starting with a basic while loop and ending with a program that takes marks as input and outputs the corresponding grade.

Uploaded by

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

VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

Name :- RAMANI AYUSH

EN No :- E21110403000110108

Sub :- java (Assignment - 1)

Sem :- S.Y B.C.A Sem-4

Page No. 1 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

1.
#include<stdio.h> int main()
{
int a=0; while(a<=10)
{
printf("%d \n",a);
a++;
}
}

Output :-

2.
#include<stdio.h>
int main()
{
short a=10;
int b;
b=a;
printf("%d short \n",a);

Page No. 2 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

printf("%d\n int",b);
}\

Output :-

3.
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b;
int op;
printf(" 1.Addition\n 2.Subtraction\n 3.Multiplication\n 4.Division\n");
printf("Enter the values of a: ");
scanf("%d",&a);
printf("Enter the values of b: ");
scanf("%d",&b);
printf("Enter your Choice : ");
scanf("%d",&op);
switch(op)
{
case 1 :
printf("Sum of %d and %d is : %d",a,b,a+b);

Page No. 3 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

break;
case 2 :
printf("Difference 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("Division of %d and %d is %d : ",a,b,a/b);
break; default :
printf(" Enter Your Correct Choice.");
break;
}
return 0;
}

Output :-

4.
#include<stdio.h>
int main()
{

Page No. 4 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

int a=1;
for(a=1;a<=10;a++)
{
printf("%d \n",a);
}
}

Output :-

5.
#include<stdio.h>
int main()
{
int a=20;
int b=10;
if(a<b)
{
printf("a is less then b ");
}
else
{
printf("a is gretar than b ");

Page No. 5 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

}
}

Output :-

6.
#include<stdio.h>
int main()
{
int a=20;
int b=10;
if(a<b)
{
printf("a is less then b ");
}
else
{
printf("a is gretar than b ");
}
}

Output :-

Page No. 6 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

7.
#include<stdio.h>
int main()
{
int a=2;
for(a=2;a<=50;a++)
{
if(a%2==0)
{
printf("%d ",a);
}
}
}

Output :-

8.
>#include<stdio.h> int main()
{

Page No. 7 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

int a=2;
for(a=2;a<=50;a++)
{
if(a%2==0)
{
printf("%d ",a);
}
}
}

Output :-

9.
#include<stdio.h>
int main()
{
int a=5; int b=10;
if(a<b)
{
printf("a is less then b ");

Page No. 8 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

}
}

Output :-

10.
#include<stdio.h>
int main()
{
int a;
int n;
printf("enter any number ");
scanf("%d",& n);
printf("odd :- ");
for(a=0; a<=n ;a++)
{
if(a%2==1)
{
printf("%d ",a);
}
}
}

Output :-

Page No. 9 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

11.
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Enter any Alphabet\n");
scanf("%c",&ch);
switch(ch)
{
case 'a':
printf("%c is a vowel",ch); break; case 'e':
printf("%c is a vowel",ch); break; case 'i':
printf("%c is a vowel",ch); break; case 'o':
printf("%c is a vowel",ch); break; case 'u':
printf("%c is a vowel",ch); break; case 'A':
printf("%c is a vowel",ch); break; case 'E':
printf("%c is a vowel",ch); break; case 'I':
printf("%c is a vowel",ch); break; case 'O':
printf("%c is a vowel",ch); break; case 'U':
printf("%c is a vowel",ch); break; default:
printf("%c is a consonant",ch); break;

Page No. 10 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

return 0;

OUTPUT:-

12.
#include<stdio.h>
int main()
{
int a=0; do
{
printf("%d \n",a);
a++;
}
while(a<=10);
}

Output :-

Page No. 11 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

13.
#include<stdio.h>
int main()
{
int marks;
printf("\n-----------------------------------");
printf("\nEnter The Marks Between 0 To 100:");
printf("\nEnter The Mark: ");
scanf("%d", &marks);
if(marks>100)
{
printf("\nDon't Be Smart Enter your Marks Between Limit\n");
}
else
{
switch(marks/10)
{
case 10 :
case 9 :

Page No. 12 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH


VIDHYADEEP INSTITUTE OF COMPUTER AND INFORMATION TECHNOLOGY ANITA KIM

printf("\n Your Grade is: A"); break; case 8 :


printf("\n Your Grade is: B" ); break; case 7 :
printf("\n Your Grade is: C" ); break; case 6 :
printf("\n Your Grade is: D" ); break; case 5 :
printf("\n Your Grade is: E" ); break; case 4 :
printf("\n Your Grade is: E--"); break; default :
printf("\n You Grade is: F or Fail\n");
}
}
return 0;
}

Output :-

Page No. 13 S.Y BCA Sem-4 PREP BY-RAMANI AYUSH

You might also like