C Assignment 3
C Assignment 3
TECHNICAL
UNIVERSITY FOR
WOMEN
PROG. IN C LANGUAGE
ASSIGNMENT
NAME – Srishti
DEPT. – CSE
ENROLLMENT NO. –
20001012022
SUBMITTED TO –
Mrs. Prerna Ma’am
ASSIGNMENT 1
Functioning of OS
RAM ROM
Read and write operations Only read operation can be
can be performed. performed.
Data stored can be lost in a Data stored cannot be lost in
volatile memory when the a non-volatile memory when
power supply is cut off. the power supply is cut off
It is faster but expensive. It is slow but less expensive.
Storage data needs to be Storage data doesn’t need to
refreshed in RAM. be refreshed in ROM.
The size of the chip is bigger The size of the chip is smaller
to store data. to store data.
Types of RAM – DRAM and Types of ROM – PROM, MROM,
SRAM EEPROM and EPROM
ASSIGNMENT 2
Example:
#include<stdio.h>
int a=50, b=40;
void main()
{
printf("a = %d and b=%d",a,b);
}
In the above example, a and b are the global variables.
Example:
#include<stdio.h>
void main()
{
int x=50, y=40;
printf("x = %d and y=%d",x, y);
}
In the above example, we have declared x and y two variables
inside the main function. Hence these are local variables.
Local variable
The reason for the limited scope of local variables is that local
variables are stored in the stack, which is dynamic in nature
and automatically cleans up the data stored within it.
Break Example:
#include<stdio.h>
main()
{
int i;
for(i=0;i<5;++i)
{
if(i==3)
break;
printf(“%d “,i);
}
}
Output:
012
Continue Example:
#include<stdio.h>
main()
{
int i;
for(i=0;i<5;++i)
{
if(i==3)
continue;
printf(“%d “,i);
}
}
Output:
0124
goto Example:
#include <stdio.h>
void main(){
printf("Hello We are Learning C Language Tutorial\n");
goto label;
printf("How Are You?"); // skipped
printf("Are You Okey?"); // skipped
label:
printf("Hope you are fine");
}
Output:
While loop:
A while loop is a control flow statement that allows code to be
executed repeatedly based on a given Boolean condition. The
while loop can be thought of as a repeating if statement.
Example-
# include <stdio.h>
int main()
{
int i = 5;
while (i < 10) {
printf("SKY\n");
i++;
}
return 0;
}
OUTPUT-
SKY
SKY
SKY
SKY
SKY
do-while loop:
do while loop is similar to while loop with the only difference
that it checks for the condition after executing the statements,
and therefore is an example of Exit Control Loop.
Example-
#include <stdio.h>
int main()
{
int i = 5;
do {
printf("SKY\n");
i++;
} while (i < 10);
return 0;
}
OUTPUT-
SKY
SKY
SKY
SKY
SKY
for loop:
for loop provides a concise way of writing the loop structure.
Unlike a while loop, a for statement consumes the initialization,
condition and increment/decrement in one line thereby
providing a shorter, easy to debug structure of looping.
Example-
#include <stdio.h>
int main()
{
int i = 0;
for (i = 5; i < 10; i++) {
printf("SKY\n");
}
return 0;
}
OUTPUT-
SKY
SKY
SKY
SKY
SKY
int main() {
int m, n, p, q, c, d, k, sum = 0;
scanf("%d", &first[c][d]);
if (n != p)
else {
scanf("%d", &second[c][d]);
multiply[c][d] = sum;
sum = 0;
printf("%d\t", multiply[c][d]);
printf("\n");
} //else ends
return 0;
} //main ends
int main()
scanf("%d", &a[i][j]);
if (j == c - 1)
printf("\n");
}
transpose[j][i] = a[i][j];
if (j == r - 1)
printf("\n");
return 0;
Output: Output:
x=20 y=10 x=20 y=10
a=10 b=20 a=20 b=10