Model PCI-1
Model PCI-1
Model PCI-1
IT Department
Model Answer Sheet of Unit Test- I
(AY-2023-2024)Summer 2024
Course & Year code:IH2K Sem:II
Class: FYCSIT Div: -H
Subject Name: PIC Sub. Code:312303
Faculty Name:Ms.S.P.Phadtare Marks:30
Que Sub
No. Que. Answer Marks
1.Break:The Break statement is used to exit from the loop constructs. The break
statement is usually used with the switch statement, and it can also use it within
the while loop, do-while loop, or the for-loop. When a break statement is
encountered then the control is exited from the loop construct immediately.
Syntax:
break;
2.Continue: The continue statement is not used to exit from the loop constructs.
The continue statement is not used with the switch statement, but it can be used
within the while loop, do-while loop, or for-loop. When the continue statement is
encountered then the control automatically passed from the beginning of the loop
statement.
Syntax:
continue;
d.Explain for loop and write c program to print 1 to 100 numbers using for
loop
for Loop in C
The for loop in C Language provides a functionality/feature to repeat a set of
statements a defined number of times. The for loop is in itself a form of an entry-
controlled loop.
Syntax of for Loop
for(initialization; check/test expression;increment/decrement)
{
// body consisting of multiple statements
}
#include<stdio.h>
int main()
{
int i;
for(i=1;i<=100;i++)
{
printf("%d\n",i);
}
}
Q.1.C Attempt the following
a.Define Array. List it’s types.
Array:An array is defined as the collection of similar type of data items stored at
contiguous memory locations. Arrays are the derived data type in C programming
language which can store the primitive type of data such as int, char, double, float,
etc.
Types of Array:
1.Single dimensional array
2.Two dimensional Array
3.Multi-dimensional array
printf():
printf() function is used in a C program to display any value like float, integer,
character, string, etc on the console screen. It is a pre-defined function that is
already declared in the stdio.h(header file).
Syntax :
printf(“Format Specifier”, var1, var2, …., varn);
int main()
{
int a;
a = 20;
// Printing the value of a variable
printf("%d", a);
return 0;
}
2.scanf():
scanf() function is used in the C program for reading or taking any value from the
keyboard by the user, these values can be of any data type like integer, float,
character, string, and many more. This function is declared in stdio.h(header file),
that’s why it is also a pre-defined function. In scanf() function we use &(address-
of operator) which is used to store the variable value on the memory location of
that variable.
Syntax:
scanf(“Format Specifier”, &var1, &var2, …., &varn);
// C program to implement scanf() function
#include <stdio.h>
int main()
{
int num1;
printf("Enter a integer number: ");
scanf("%d", &num1);
printf("You have entered %d", num1);
return 0;
}
case constant-expression :
statement(s);
break; /* optional */
case constant-expression :
statement(s);
break; /* optional */
if (A >= B) {
if (A >= C)
printf("%d is the largest number.", A);
else
printf("%d is the largest number.", C);
}
else {
if (B >= C)
printf("%d is the largest number.", B);
else
printf("%d is the largest number.", C);
}
return 0;
}
c.Develop a c program to print even numbers between 1 to 100 using while loop
and draw flowchart.
return 0;
}
Algorithm
1. Start
2. Initialize the variable i to 1.
3. while i<=100
4. if i%2==0
5. print the number
6. increment value of i
7. stop
Flowchart
a.Explain how to initialize and declare of one dimensional and two dimensional
arrays.