Yash Kushwaha Pratical PC New
Yash Kushwaha Pratical PC New
11
Name: Yash Kushwaha class :BCA 1st (E)
Aim: Write a C Program to understand the use of continue and break statement
BREAK STATEMENT:
The break statement can also be used to jump out of a loop. This example jumps
out of the loop when i is equal to 4:
#include<stdio.h>
#include <conio.h>
void main()
{
int i;
clrscr( );
for (i = 0; i < 10; i++)
{
if (i == 4)
{
break;
}
printf("%d\n", i);
getch( );
}
CONTINUE STATEMENT:
The continue statement breaks one iteration (in the loop), if a specified condition
occurs, and continues with the next iteration in the loop. This example skips the
value of 4
#include<stdio.h>
#include <conio.h>
void main( )
{
int i;
clrscr( );
for (i = 0; i < 10; i++)
{
if (i == 4)
{
continue;
}
printf("%d\n", i);
getch( );
}
Name: Yash Kushwaha class :BCA 1st (E)
PROGRAM NO. 12
Aim: Write a C Program to input values into an array and display them.
#include<stdio.h>
#include<conio.h>
void main()
{
int arr[5],i;
clrscr( );
for(i=0; i<5; i++)
{
printf("Enter the value for arr[%d] : ",i);
scanf("%d", &arr[i]);
}
printf("The array elements are : \n");
OUTPUT :-
Enter the number of terms: 10
Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34
Salary: 60000
Bonus: 5000
Name: Yash Kushwaha class :BCA 1st (E)
PROGRAM NO. 20
Aim: Write a C++ Program to Implement Multi level Inheritance.
C++ Multilevel Inheritance
In C++ programming, not only you can derive a class from the base class but you
can
also derive a class from the derived class. This form of inheritance is known as
multilevel
inheritance.
class A {
... .. ...
};
class B: public A {
... .. ...
};
class C: public B {
... ... ...
};
Here, class B is derived from the base class A and the class C is derived from the
derived
class B.
C++ Program
#include <iostream>
using namespace std;
class A
{
public:
void display()
{
cout<< " Base class content.";
}
};
class B : public A
{
};
class C : public B
{
};
void main( )
{
C obj;
obj.display( );
getch( );
}
OUTPUT :-
Base class content.
Length = 5.5