BSc AI&ML/Bca/it/cs (Question-with answer C1 paper)
type-1: (Group-A) 1*1=10 marks:
Q1.who invented by c and c++ ?
Q2. what is "printf","scanf"and also define cout & cin?
Q3. define data type, keyword and variable in short words?
Q4. what is constructor and destructor in c++?
Q5. what is point and Arry? Or what is class and object?
Q6. what is full form of ASCII and also define Ascii value of "a"?
Q7. what is the extension of c++ and also define syntax error?
Q8. Write a program in c++ to check large number between three numbers (to take
number for user)?
Q9. define encapsulation? or write access specifiers in class?
Q10.what is string and define of strlen( ) function?
type-2: (Group-B) 1*5=5 marks:
Q.11 what is function and also define call by value and call by reference? or what is
inline function and it's characteristic?
Q12.what is recursion (recursive function) and use of recursion to print factorial? or
WAP in c++ to print Fibonacci numbers series?
Q13.difference between oop's and pop (mention any five features of oops)?
Q14.check whether number is prime or not prime? Or WAP in c++ to covert the
temperature in Celsius to Fahrenheit and vice-versa?
Q.15 what is polymorphism and types of polymorphism (function overloading and
function overriding)?
type-3: (Group-C) 15*3=45 marks:
Q16.what is inheritance and types of inheritance (with short an example code)?
Q17.what is file handling & it's types and operation?
Q18.Explain loop control statements of 'c' with example?
Q19. differentiate "c" and "c++" language?
Q20. write a program to print a tringle of stares as follows (take number of lines from
user)?
(a) * (b) 1 (c) A
* * 2 2 A B
* * * 3 3 3 A B C
Q21.Write a program in c++ to enter recorders of 10 students. recorders contents roll
number, name and marks of five subjects that display roll number, name and total of 5
subjects marks? or WAPIC to check the given number format is in binary or not?
sol: -1
⦁ C was invented by Dennis Ritchie in the early 1970s at Bell Labs.
⦁ C++ was invented by Bjarne Stroustrup in 1979, also at Bell Labs.
sol: -2
⦁ printf is a function in C language used to print output to the screen.
⦁ scanf is a function in C language used to take input from the user.
⦁ cout is a function in C++ language used to print output to the screen.
⦁ cin is a function in C++ language used to take input from the user.
sol: -3
⦁ data type defines what kind of data a variable can hold.
⦁ Keyword a reserved word in a programming language that has a specific
meaning in programming language and cannot be used as a variable name.
⦁ Variable as a container that holds data which can be changed during program
execution.
sol: -4
⦁ Constructor is a special type of function which is automatically called at the
time of object creation. It's used to initialize the object's data (variables).
⦁ Destructor is an also special type of member function that is used to deallocate
the memory, allocated by the constructor.
sol: -5
⦁ Array is a collection of similar type of data. It's stored data contiguous memory
location. Array index always starts form zero.
⦁ pointer is a variable that can able to hold address of another variable.
Or
⦁ A class is like a blueprint for creating objects. It defines properties (variables)
and behaviors (functions) that the objects created from it will have.
⦁ An element of a class is known as object. (In another word an object is an
instance of a class).
sol: -6
⦁ The full form of ASCII is American Standard Code for Information Interchange.
ASCII value of "a"=97.
sol: -7
⦁ The typical file extension for C++ source code files is .cpp. For header files, it is
usually .h or .hpp.
⦁ A syntax error occurs when the code does not follow the rules or grammar of the
programming language. This can happen if you forget a semicolon, parentheses
and other operators etc. It is also known as compile time error.
sol: -8
#include<iostream>
using namespace std;
int main ()
int a,b,c;
cout<<"Enter a first number:"<<endl;
cin>>a;
cout<<"Enter a second number:"<<endl;
cin>>b;
cout<<"Enter a third number:"<<endl;
cin>>c;
if(a>b&&a>c) {
cout<<"largest number is:"<<a;
} else if (b>a&&b>c){
cout<<"largest number is:"<<b;
}else{
cout<<"largest number is:"<<c;
return 0;
sol: -9
⦁ data encapsulation is the concept of oops,that is used to wrap the data member
and member function into a single unit is known as data encapsulation.
Or
⦁ Access specifiers
1.public
2.private
3.protected
sol: -10
⦁ A string is a sequence of characters, like a word or sentence, stored in memory.
⦁ The strlen() function in C++ is used to find the length of string, it returns the
number of characters in the string, excluding the null character "\0".
sol: -11
⦁ Function is a block of code that performs particular task. Functions help make
code reusable and organized.
⦁ we pass value of variable as argument is called call by value. Or (Passing a copy
of the variable, changes don't affect the original value is known as call by value.)
⦁ we pass address of variable as argument is called call by reference. Or
(Passing the actual variable, changes affect the original value is known as call
by reference.)
Or
⦁ An inline function in C++ is a function where the code is directly inserted at the
place where the function is called. This helps make the program run faster
because it avoids the extra steps of calling a function, especially for small
functions that are used often.
⦁ Characteristics of Inline Functions: -
a) Inline function execute the program is very fast.
b) only small function should be inline.
c)Inline function cannot support of the following.
1)Loop, Switch, goto function.
2)cannot be recursive function
d) Inline function defined with inline keyword.
e) Inline function reading program at compile time.
sol: -12
⦁ When a function calls itself, it's called recursion.
⦁ properties of recursion: -
(a)Anything that can be done with iteration, can be done with recursion and vice-versa.
(b)Base case is the condition which stop recursion.
(c)Recursion can sometimes give the simplest solution.
(d) iteration has infinite loop & recursion has stack overflow.
#include<iostream>
using namespace std;
int factorial (int n){
if(n==1){return 1;
}else{
return n*factorial(n-1);
}
int main()
int num;
cout<<"Enter a number:";
cin>>num;
cout<<"factorial= "<<factorial(num);
return 0;}
Or
#include<iostream>
using namespace std;
int main(){
int n,fibonacci,first=0, second=1;
cout<<"Enter a number:\n";
cin>>n;
if(n>=1){
cout<<first;
if(n>=2){
cout<<","<<second;
}for(int i=2;i<=n;i++){
fibonacci=first+second;
cout<<","<<fibonacci;
first=second;
second=fibonacci;
return 0;
sol:-13
Difference b/w pop and oop is define following: -
(a) pop follows top-to down approach (a) oop follows bottom-up approach.
(b) It takes very less memory (b)It takes more memory than pop.
(c) In pop data hiding is not possible (c)In oop data hiding is possible.
(d) their is no any access specifier (d)It have access specifier like
public,private,protected.
(e) In pop, we cannot perform (e) In oop overloading is possible.
Overloading.
(f) programming is dividing into small (f)programming is dividing into small parts called
parts called function objects.
(g) pop means procedural oriented (g) oop means object-oriented programming.
programming.
(h) Example of pop C,Cobol,..etc.. (h) Example of oop c++,java, python..etc.
* Features of oop:-
1.Encapsulation
2.Abstraction
3.polymorphism
4.inheritance
5.composition
6. class & object
sol: -14
#include<iostream>
using namespace std;
int main()
int n,count=0;
cout<<"Enter a number:\n";
cin>>n;
for(int i=1;i<=n;i++){
if(n%i==0){
count++;
if(count==2){
cout<<"number is prime:"<<n;
}else{
cout<<"number is not prime:"<<n;
}
return 0;
Or
#include<iostream>
using namespace std;
int main(){
int celsius,fahrenheit;
cout<<"Enter temperature in celsius:\n";
cin>>celsius;
fahrenheit=(9/5*celsius)+32;
cout<<"fahrenheit:"<<fahrenheit;
cout<<"\nEnter temperature in fahrenheit:\n";
cin>>fahrenheit;
celsius=(fahrenheit-32)*5/9;
cout<<"celsius:"<<celsius;
return 0;
sol: -15
⦁ Polymorphism is one of the core concepts of Object-Oriented Programming
(OOP). It means "many forms" and allows objects of different classes to be
treated as objects of a common superclass. The key idea is that a single action
or method can behave in multiple ways depending on the type of object it is
acting upon.
⦁ Types of Polymorphism:
1. Compile-time Polymorphism (also called Static Polymorphism or early binding)
2. Run-time Polymorphism (also called Dynamic Polymorphism or late binding)
Note:- they are implemented through different mechanisms like Function Overloading
and Function Overriding.
⦁ Function Overloading (Compile-time Polymorphism): Multiple functions with the
same name but different parameters is called function overloading. This
polymorphism exists at the time of compile.
⦁ Function overriding (runtime polymorphism) whenever we writing method in
base and derived class in such a way that function name & parameter must be
same called as function overriding. This polymorphism exists at the time of
execution of program.
sol: - 16
⦁ Inheritance is a concept in object-oriented programming (OOP) where a class
acquires properties and behaviors of another class. This helps in code
reusability.
⦁ Types of inheritance: -
1. Single Inheritance: - A derived class inherits from one Base (parent) class.
2. Multiple Inheritance: - A child class inherits from more than one parent class.
3. Multilevel Inheritance: - A class is derived from another derived class.
4. Hierarchical Inheritance: - Multiple classes inherit from a single parent class.
5. Hybrid Inheritance: - Combination of two or more types of inheritance.
Note: - you write your own example in c++ code because I don’t write example in this
pdf. I have much time expend in this pdf.
sol: -17
⦁ file handling is a mechanism so that we can store the output of the program in
the file and we can perform many operations on the data present in a file.
⦁ Types of Files in File Handling: -
⦁ Text File: A file that stores data in human-readable format (like .txt, .csv).
⦁ Binary File: A file that stores data in a non-human-readable format, used for
storing data like images, videos, etc. (like .jpg, .exe).
⦁ Operation on files: -
1. create a file
2. open a file
3. close a file
4. read a file
5. write in a file
⦁ File Handling Types in C++:
⦁ Input File Stream (ifstream): Used for reading from files.
⦁ Output File Stream (ofstream): Used for writing to files.
⦁ File Stream (fstream): Used for both reading from and writing to files.
Sol: - 18
⦁ In C programming, loop control statements are used to control the flow of
execution within loops. The three main loop control statements in C are.
1. break
2. continue
3. goto
⦁ break Statement: -The break statement is used to terminate the loop
prematurely.
#include <stdio.h>
int main() {
for (int i = 1; i <=34; i++) {
if (i ==7) { break;}
printf("%d ", i);
return 0;
} output: 1,2,3,4,5,6,7
⦁ continue Statement: -The continue statement is used to skip the current
iteration of the loop and proceed to the next iteration, without terminating the
loop.
#include <stdio.h>
int main() {
for (int i = 1; i <= 7; i++) {
if (i ==4) { continue; }
printf("%d ", i);}
return 0;
} output: 1,2,3,5,6,7
⦁ goto:- Jumps to a specific location in the code, but should be used cautiously.
#include<stdio.h>
int main()
{ int i=1; label:
printf("%d",i);i++;
if(i<=10)
goto label;
return 0;} output: 1 2 3 4 5 6 7 8 9 10
Sol: - 19
Sol: -20
(a)#include<iostream>
using namespace std;
int main(){
int n,i,j;
cout<<"Enter a number:";
cin>>n;
for(i=1;i<=n;i++){
for(int k=n;k>=i;k--){
cout<<" ";
for(j=1;j<=i;j++){ //Note: for second question i.e.(b)
cout<<"* ";// replace it cout<<i<<" "; and you have got answer
cout<<endl;
return 0;
(c)#include<iostream>
using namespace std;
int main()
int n,i,j;
char x='A';
cout<<"Enter a number of rows:\n";
cin>>n;
for(i=1;i<=n;i++){
for(j=1;j<=i;j++){
cout<<x;
x++;
cout<<endl;
x='A';
return 0;
Some key points: -
Abstraction: - Hiding all unnecessary details & showing only the important parts.
String: - A string is a sequence of characters, which ends null character ('\0').
Structure: - A structure is a collection of different types of data.
Loop: - A loop is a programming structure that repeats a block of code as long as a
specified condition is true. Three types of loop(for,while,do while loop).
Function: - A function is a block of code designed to perform a specific task. It allows
you to reuse the code by calling the function multiple times.
There are two types of function:
1.pre define function/built in function:- A function that is already defined in a
programming languages.
2. user define function: - A function created by the programmer to perform a
specific task, defined with a name and a set of instructions.
Local variable: - A local variable is a variable defined inside a function or block.
Global variable: - A global variable is a variable defined before the main function.
Macro: -A macro is a label defined in the source code that is replaced by its value by
the preprocessor before compilation. It Initialize with #define
(Example #defune pi 3.14)
Ternary operator: - the ternary operator is a conditional operator that evaluates an
expression and returns one of two values based on a condition.
Syntax:
condition? value_if_true : value_if_false;
Modularity: -The process which is used for divide the program in multiple parts is
known as modularity.
Note: - I try to explain all important topics in our exam point of view but may be some
topics are missing in this pdf. Because I have some knowledge but you have more
knowledgeable person. You know how to read, how to write in your exam. I think you
will get 50 to 60 marks and more (depending your luck) with the help of this pdf.
(Previous year question paper link below click to link and send request access)
Click on here