0% found this document useful (0 votes)
6 views31 pages

Unit 1 - POP Question Bank

The document outlines the basic organization of a computer, detailing its five major operations: input, storage, processing, output, and control. It explains the differences between primary and secondary memory, various programming design tools like algorithms and flowcharts, and provides examples of C programs for arithmetic operations, data types, and control structures. Additionally, it covers concepts such as tokens, relational operators, and bitwise operations in C programming.

Uploaded by

akshu11vraj
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)
6 views31 pages

Unit 1 - POP Question Bank

The document outlines the basic organization of a computer, detailing its five major operations: input, storage, processing, output, and control. It explains the differences between primary and secondary memory, various programming design tools like algorithms and flowcharts, and provides examples of C programs for arithmetic operations, data types, and control structures. Additionally, it covers concepts such as tokens, relational operators, and bitwise operations in C programming.

Uploaded by

akshu11vraj
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/ 31

1. Briefly explain basic organisation of computer.

A computer is an electronic device which basically performs five major operations which
includes:
1) accepts data or instructions (input)
2) stores data
3) process data
4) displays results (output) and
5) controls and co-ordinates all operations inside a computer

• Input: This is the process of entering data and instructions into the computer. Different input
devices such as mouse, keyboard, scanner and trackball can be used to enter the instructions.
It is the responsibility of the input device to convert the input data into binary code.
• Storage: This is the process of saving data and instructions permanently in the computer such
that it can be used for processing. There are 2 types of storage areas

1. Primary storage (Main memory): This area stores data, intermediate results and
recently generated results that
are currently being worked on.
⮚ The storage area that is directly accessible by the CPU at very high speed.
⮚ It is very expensive, limited capacity and volatile.
⮚ Eg : Random Access memory

2. Secondary Storage (Auxiliary Memory): this area stores the data that is not
accessed frequently (as compared to the data in primary storage.
⮚ It is a non-volatile memory medium that preserves data until and unless it has
been deleted or overwritten.
⮚ It supplements the limited storage capacity of primary memory
⮚ Eg : CD , Hard disk drives, Magnetic disk
• Input: This is the process of entering data and instructions into the computer. Different
input devices such as mouse, keyboard, scanner and trackball can be used to enter the
instructions. It is the responsibility of the input device to convert the input data into
binary code.
• Storage: This is the process of saving data and instructions permanently in the computer
such that it can be used for processing. There are 2 types of storage areas

1. Primary storage (Main memory): This area stores data, intermediate results and
recently generated results that
are currently being worked on.
⮚ The storage area that is directly accessible by the CPU at very high speed.
⮚ It is very expensive, limited capacity and volatile.
⮚ Eg : Random Access memory

2. Secondary Storage (Auxiliary Memory): this area stores the data that is not
accessed frequently (as compared to the data in primary storage.
⮚ It is a non-volatile memory medium that preserves data until and unless it
has been deleted or overwritten.
⮚ It supplements the limited storage capacity of primary memory
⮚ Eg : CD , Hard disk drives, Magnetic disk

2. Mention the differences between primary and secondary memory.

Primary memory Secondary memory

Known as main memory or internal memory Known as auxiliary memory or External memory

Eg : RAM, ROM , Cache, EPROM Eg: HDD , CD, DVD ,Flash drives

Volatile memory : Non volatile memory:


Temporarily stores device while in use Permanently stores data

CPU directly accesses data CPU does not directly accesses data

Power cut causes loss of data Power cut does not cause loss of data

Limited storage capacity Expansive and scalable


Faster data access Slower data access
3. List out the differences between compiler and interpreter.

4. List and explain the different program design tools.


Algorithms
a. Step by step description on how to arrive at a solution.
b. It provides a blueprint of the solution
c. It should be precise , Unambiguous , Once the algorithm terminates the desired
result must be obtained.

Flowcharts
d. Graphical or symbolic representation of a process.
e. Helps user to visualize the logic of the process which helps them to understand
the process better , find flaws , bottlenecks.

Pseudocodes
f. Compact and informal high level description of an algorithm
g. Helps user to focus on the logic of the algorithm without worrying about the
details of language syntax.
h. An ideal pseudocode must be complete , descriptive such that it can be translated
to a programming language straightaway.

5. Define flowchart and list out the different symbols used to represent a flowchart.
Flowchart are the graphical representation of a solution to a particular problem, which
comes under the category of programming practices and techniques.

6. Write the structure of the C Program.

7. Write a C program to read Grade, CGPA, age and phone number and print the same as
the output.
#include<stdio.h>
void main()
{
char gr;
float cg;
int age,num;
printf("enter grade & cgpa : \n");
printf("enter age and phone num : \n");
scanf("%c%f",&gr,&cg);
scanf("%d%d",&age,&num);
printf("\n grade is : %c",gr);
printf("\n cgpa is : %f",cg);
printf("\n age is : %d",age);
printf("\n phone num is : %d",num);
}
8. Write a C program to perform basic arithmetic operations such as sum, difference,
product and quotient i)fixed values of operands ii)on user entered value of operands. Print
result of each operation . [Note: in divide assume no 0 is entered by the user]
#include <stdio.h>
int main() {
// Part i: Using fixed values
int a = 20, b = 10;
printf("Using Fixed Values:\n");
printf("a = %d, b = %d\n", a, b);
printf("Sum = %d\n", a + b);
printf("Difference = %d\n", a - b);
printf("Product = %d\n", a * b);
printf("Quotient = %d\n\n", a / b); // assuming b != 0

// Part ii: Using user input


int x, y;
printf("Using User Input:\n");
printf("Enter two integers (non-zero divisor): ");
scanf("%d %d", &x, &y);
// Assumption: y != 0
printf("x = %d, y = %d\n", x, y);
printf("Sum = %d\n", x + y);
printf("Difference = %d\n", x - y);
printf("Product = %d\n", x * y);
printf("Quotient = %d\n", x / y);
return 0;
}

9. What are C tokens? List types.

Tokens are the smallest elements of a C program.


Types:

● Keywords

● Identifiers

● Constants

● Strings

● Operators

● Special Symbols

10. What are basic data types in C?

● int: Integer numbers

● float: Single precision floating point

● double: Double precision

● char: Character

11. Write a program to check if a number is even or odd.

#include <stdio.h>

int main() {
int num;

printf("Enter a number: ");

scanf("%d", &num);

if(num % 2 == 0)

printf("Even");

else

printf("Odd");

return 0;

12. Write a C program to find area of a rectangle.


#include <stdio.h>
int main() {
float length, breadth, area;
printf("Enter length and breadth: ");
scanf("%f %f", &length, &breadth);
area = length * breadth;
printf("Area = %.2f", area);
return 0;
}
13. Write a program to swap two variables.
#include <stdio.h>
int main() {
int a = 5, b = 10, temp;
temp = a;
a = b;
b = temp;
printf("a = %d, b = %d", a, b);
return 0;
}

14. Write a C program that takes hours and minutes as input, and calculates the total number
of minutes.
#include <stdio.h>
int main() {
int hours, minutes, totalMinutes;
printf("Enter hours: ");
scanf("%d", &hours);
printf("Enter minutes: ");
scanf("%d", &minutes);
totalMinutes = (hours * 60) + minutes;
printf("Total minutes = %d\n", totalMinutes);
return 0;
}

15. Write a program that checks if a number is odd and divisible by 3 but not by 5.

#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if ((num % 2 != 0) && (num % 3 == 0) && (num % 5 != 0))
{
printf("Number meets the condition.\n");
}
else
{
printf("Number does not meet the condition.\n");
}
return 0;
}
16. Predict the output
int x = 10, y;
y = x++ + ++x;
printf("x = %d, y = %d\n", x, y);

Solution:

● x++ is 10, but x becomes 11 afterward

● ++x makes x = 12, value used is 12

● So y = 10 + 12 = 22, and x = 12

Output: x = 12, y = 22

17. What will be the output?


int a = 2, b = 1;
int result = a & b || b ^ a;
printf("%d\n", result);

Solution:
● a & b = 2 & 1 = 0 (binary: 10 & 01 = 00)

● b ^ a = 1 ^ 2 = 3 (01 ^ 10 = 11)

● 0 || 3 = 1

Output: 1

18. Predict the output of the following expression:

int a = 5, b = 10, c = 3;
int result = a + b * c - ++a / c;
printf("%d\n", result);

Solution:

● Step-by-step evaluation:

○ ++a makes a = 6

○ b * c = 10 * 3 = 30

○ ++a / c = 6 / 3 = 2

○ Final result: a + b * c - ++a / c = 6 + 30 - 2 = 34

Output: 34

19. Implement a C program to find the distance between two points.


20.Predict the Output for the following code.

#include<stdio.h>
void main(){

int a=10,b=15,c=20,d=25;
printf("++a= %d \n",++a);
printf("++b=%d \n",++b);
printf("c++=%d \n",c++);
printf("d++=%d \n",d++);
printf("++a=%d \n",++a);
printf("++b=%d \n",++b);
printf("c++=%d \n",c++);
printf("d++=%d \n",d++);
}

Output
++a= 11
++b=16
c++=20
d++=25
++a=12
++b=17
c++=21
d++=26

21.Predict the Output for the following code.

#include<stdio.h>
int main()
{
int a = 1, b = 1, c;
c = a++ + b;
printf("%d, %d", a, b);
}

a) a = 1, b = 1
b) a = 2, b = 1 ←ANS
c) a = 1, b = 2
d) a = 2, b = 2
22.Writea C Program , taking two integer values as 10
and 2, demonstrate the integer arithmetic operations
by
Printing the following on the monitor
10+2=12
10-2=8
10*2=20
10/2=5
10 % 2 =0

#include<stdio.h>
void main(){
int c,d,e,f,g;

int a=10,b=2;
c = a+b;
d=a-b;
e=a*b;
f=a/b;
g=a%b;
printf("%d + %d= %d \n",a,b,c);
printf("%d-%d=%d\n", a, b,d);
printf("%d*%d=%d\n", a, b,e);
printf("%d/%d=%d\n", a,b,f);
printf("%d %% %d=%d\n", a,b,g);

OUTPUT
10 + 2= 12
10-2=8
10*2=20
10/2=5
10 % 2=0

23.Write a C program to use integer arithmetic to


convert a given number of days into months and
days.

/* Program to show integer arithmetic */


#include<stdio.h>
void main()
{
int days,month,rem_day;
printf(“Enter the number of days :");
scanf("%d",&days);
month = days / 30;
rem_day= days % 30;
printf(“Months = %d \n Days = %d", month, rem_day);
}

Output
Enter the number of days:265
Months = 8
Days = 25
24.Program to show working of Relational operators.
#include<stdio.h>
void main()
{
int a=10,b=20;
printf("%d<%d =%d \n",a,b,a<b);
printf("%d>%d =%d\n",a,b,a>b);
printf("%d<=%d =%d\n",a,b,a<=b);
printf("%d>=%d =%d\n",a,b,a>=b);
printf("%d==%d =%d\n",a,b,a==b);
printf("%d!=%d =%d\n",a,b,a!=b);
}

Output

10<20=1
10>20=0
10<=20=1
10>=20=0
10==20 = 0
10!=20 = 1
25.Program to show working of Relational operators.

#include<stdio.h>
void main()
{
int a=10,b=11,c=12,d;
d=(a<b)&&(c<b);
printf(" d = %d",d);
d= (a<b)||(c<b);
printf("\n d = %d",d);
}

Output
d=0
d=1

26.Write C program to find largest of 3 numbers


using ternary operators

#include<stdio.h>
void main()
{
int a,b,c;
int result;
printf("enter the values of 3 numbers");
scanf("%d%d%d",&a,&b,&c);
result = (a>b && a>c)?a:(b>c)?b:c;
printf("%d is biggest ",result);
}

Output
enter the values of 3 numbers6
45
6
45 is biggest
27.Write a C program to find if a number is odd or
even using ternary operator

#include <stdio.h>
int main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);
(num % 2 == 0) ? printf("%d is even.\n",
num) : printf("%d is odd.\n", num);
return 0;
}

28.Program to demonstrate bitwise operation

#include<stdio.h>

void main()
{
int a=60 ,b=13;
int c;
c=a&b;
printf("\n bitwise and : c= %d",c);
c=a|b;
printf("\n bitwise or : c=%d",c);
c=~a;
printf("\n bitwise complement : c=%d",c);
c=a ^ b;
printf("\n bitwise xor : c=%d",c);
c=a<<2;
printf("\n left shift : c=%d",c);
c=a>>2;
printf("\n right shift : c=%d",c);
}

29.Solve:a+2 > b && !c||a !=d&&a-2<=e


where a=11 b=6 c=0 d=7 e=5

11+2>6 && !0||11 != 7 && 11-2<=5


11+2>6 && 1||11 != 7 && 11-2<=5
13>6 && 1 || 11 !=7 && 11-2<=5
13>6 && 1 || 11 !=7 && 9<=5
1 && 1 || 11 !=7 && 9<=5
1 && 1 || 1 && 9<=5
1 && 1 || 1 && 0
1 || 1 && 0
1 || 0 = 1
30.Explain Type Conversion with Examples.
►Type conversion is carried out when an
expression has data of different types.
►It is a process of converting data of one type to
another
►There are 2 ways in which this is done
1. Implicit type conversion 2. Explicit Type
conversion
1.IMPLICIT TYPE CONVERSION : When the
conversion is automatically carried out by the
compiler without the programmers intervention .
float b;
b=150;
printf(“b= %f”,b); Output :
150.000000

2. EXPLICIT TYPE CONVERSION

There will be instances when we would want


to force a type conversion in a way different
than the automatic conversion.
SYNTAX: (type-name)EXPRESSION
Ex:
int female_students, total_students;
Ratio = female_students / total_students
(decimal portion is lost and hence

doesn’t give a accurate result)


Ratio = (float) female_students /
total_students ;
31.Define Identifiers.Explain the rules for
Identifiers.
Sol:Identifiers (Variables)
Identifiers are user-defined names
Names of variables, functions and arrays as
declared by user
Rules for identifiers
● First character must be an alphabet or
underscore
● Remaining characters can be letters, digit or
underscore
● Must not contain white space or any special
charcters
● Keywords cannot be used as identifiers
● There cannot be two successive underscores
32.Write the Algorithm and flowchart to convert
temperature from i)celsius to fahrenheit.
ii)fahrenheit to celsius.
33.Write the Algorithm and flowchart to find
Area and Perimeter of Square.
34.Write the Algorithm and flowchart to find
Area and Perimeter of Rectangle.
35.Write the Algorithm and flowchart to find
Area and Perimeter of Circle.
36.Write the Algorithm and flowchart to find
Area and Perimeter of Triangle.
37.Write the Algorithm and flowchart to find
Simple Interest and Compound Interest.
Write the Algorithm and flowchart
38.Write the Algorithm and flowchart to Swap
two numbers with and without using temporary
variable.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy