Professional Documents
Culture Documents
Solution to
Model Question Paper-1
Problem Solving Through Programming
WELCOME
Let us
EXPLORE ELECTRONICS
Do Subscribe
EXPLORE ELECTRONICS
1.Bit:-
The data are represented by the state of electronic switches. A switch with
ON state represents 1 and OFF state represents 0 (zero). These values which represent the state of a switch are called bits.
Example:-
In other words, the binary digits 1 and 0 are called bits. Thus, a bit is the smallest unit of data.
2. Nibble:-
Definition: A group of 4 bits (a half byte) is called a nibble or 1⁄2 byte.
Example:
An integer 9 can be represented using a nibble as shown below:
1001= nibble
3. Byte:-
A group of 8 bits is called a byte.
A byte is the smallest unit of data that can be manipulated by a computer at any given time. After accessing a byte, the bits
or nibbles can be manipulated.
Click here
For Videos
4. Word:-
A word is the unit of information in which information may be stored, transmitted, or operated within a given
computer.
1 word = 16 bits (or 2 bytes)
5. Kilobyte:-
Primary Memory:-
•The memory that is accessible directly by the CPU of a computer is called primary memory.
•This memory is part of the main computer system which is plugged into the motherboard along with the CPU.
•Hence, this memory is also called internal memory or main memory.
•This primary memory allows the CPU to store and retrieve data quickly.
The primary memory is divided into the following types:
•Random Access Memory (RAM): SRAM and DRAM
•Read Only Memory (ROM, PROM, EPROM, EEPROM)
•Cache memory (L1, L2 and L3)
•CPU registers
Secondary Memory:-
•The memory that is not part of the computer’s main memory and which is not directly connected to the CPU but connected to the motherboard
through ports and connectors is called secondary memory.
•In secondary memory, we can store all the data and programs permanently and can be moved from one place to another place and can be
connected to another computer.
•The secondary memory is also called auxiliary memory.
•The data and instructions are loaded from secondary memory to main memory so that the CPU can process the data.
•Ex: floppy diskette, hard disk, CD-ROMs, magnetic tapes, Blu-ray disk, flash memory (Pen drive), etc.
•The different types of storage devices are shown below:
•Floppy disk (1.2MB and 1.44MB) which is obsolete
•Hard disk (500GB to 4TB)
•Magnetic Tape (20TB)
•Optical discs: CD-ROM, DVD-ROM, Blue-Ray Disk
•Flash memory
Click here
For Videos
In C programming, an enumeration type (enum) is a data type that consists of integral constants.
Identifiers represent the name in the C program, for example, variables, functions, arrays, structures, unions,
labels, etc.
#include<stdio.h>
int main() {
float radius, area;
return (0);
}
Click here
For Videos
One similarity between while and for loop is that they both are entry
controlled loops i.e. they both will check the condition for true or false. If the
condition is true then only the entry within the loop is permitted
https://www.youtube.com/watch?v=aBPhdHD0Ykc
Click here
For Videos
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,m;
clrscr();
printf("\n Enter lower limit and upper limit");
scanf("%d%d", &m, &n);
printf("\n Numbers from %d to %d are \n", m, n);
for(i=m; i<=n; i++)
printf("%5d",i);
getch();
}
Output:
Enter lower limit and upper limit
10 20
Numbers from 10 to 20 are
10 11 12 13 14 15 16 17 18 19 20
Click here
For Videos
https://www.youtube.com/watch?v
=aBPhdHD0Ykc
Click here
For Videos
https://www.youtube.com/watch?v=sF4Z6lg3ldU
https://www.youtube.com/watch?v=nTbqeNByA78
Click here
For Videos
Click here
For Videos
https://www.youtube.com/watch?v=Y-NopiWOrHo
Click here
For Videos
Click here
For Videos
“String is a variable-length data stored in a character array”.
A string is a sequence of elements of the char data type.
As strings are variable-size data we have to represent them using character Arrays.
#include<stdio.h>
#include<string.h>
main(){
char s1[10],s2[10],s3[10]; output:-
printf("Enter String 1\n"); Enter String 1
gets(s1); abcd
printf("Enter String 2\n"); Enter String 2
gets(s2); efgh
printf("Before Swapping\n"); Before Swapping
printf("String 1 : %s\n",s1); String 1: abcd
printf("String 2 : %s\n",s2); String 2: efgh
strcpy(s3,s1); After Swapping:
strcpy(s1,s2); String 1: efgh
strcpy(s2,s3); String 2: abcd
printf("After Swapping:\n");
printf("String 1 : %s\n",s1);
printf("String 2 : %s\n",s2);
}
Click here
For Videos
#include<stdio.h>
void main()
{
int a[10], n, i, j, temp;
printf("Enter the number of elements\n");
scanf("%d", &n);
printf("Enter the array elements\n");
for(i=0; i<n; i++)
scanf("%d", &a[i]);
for(j=1; j<n;j++) https://www.youtube.com/watch?v=XtP00_rzUuk
{
for(i=0;i<n;i++)
{
if(a[i]>a[i+1])
{
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
}}}
printf("The sorted array is\t");
for(i=0; i<n;i++)
printf(“%d\t”,a[i]);
}
Click here
For Videos
Output is inidaca
https://www.youtube.com/watch?v=ndT0gSvCXBc
Click here
For Videos
Call by Value is a method in which it Call by Reference is a method in which it
passes the copies of actual parameters to passes the reference or address of the
the formal parameters inside the function. actual parameter to the function's formal
And as you know, it passes the copies, so parameters, which means if there is any
even if there is any change in the values change in the values inside the function, it
inside the function, it will not reflect that reflects that change in the actual values.
change in the actual values.
Click here
For Videos
“Functions are independent program modules that are designed to carry out a particular task.”
They are also called as argument list. They are also called as dummy parameters.
The variables used in the function call is The variables defined in function header are
called actual parameters. called formal parameters.
These are used in calling function when a These are used in function header of the called
function is called or invoke. function.
Actual parameters sends data to the formal Formal parameters receives data from actual
parameters. parameters.
Click here
For Videos
https://www.youtube.com/watch?v=E2fW4NQMZqI
Click here
For Videos
#include <stdio.h>
struct student
{
char name[30];
int rollNo;
struct DOB
{
int dd;
int mm;
int yy;
}DOB;/*created structure variable DOB*/
};
int main(){
struct student std;
printf("Enter name: ");
scanf("%C",&std.name);
printf("Enter roll number: ");
scanf("%d",&std.rollNo);
printf("Enter Date of Birth [DD MM YY] format: ");
scanf("%d%d%d",&std.DOB.dd,&std.DOB.mm,&std.DOB.yy);
printf("\nName : %s \nRollNo : %d \nDate of birth : %02d/%02d/%02d\n",std.name,std.rollNo,std.DOB.dd,std.DOB.mm,std.DOB.yy);
return 0;
}
Click here
For Videos
Click here
For Videos
Pointer arithmetic is very important to understand if you want to have complete knowledge of pointer. In this topic, we will study
how the memory addresses change when you increment a
pointer.
In a 16 bit machine, the size of all types of the pointer, be it int, float, char*, or double* is always 2 bytes. But when we
perform any arithmetic function like increment on a pointer, changes occur as
per the size of their primitive data type.
int*i;
i++
In the above case, the pointer will be 2 bytes. And when we increment it, it will increment by 2 bytes because int is
also of 2 bytes.
float*i;
i++;
In this case, the size of a pointer is still 2 bytes. But now, when we increment it, it will increment by 4 bytes because
the float is 4 bytes.
Click here
For Videos
THANK YOU
EXPLORE ELECTRONICS
Click For Videos: https://www.youtube.com/c/ExploreElectronics
All The Best For Exams….
https://www.youtube.com/c/ExploreElectronics