Important Instructions To Examiners:: Define The Terms: I) Flow Chart Ii) Algorithm
Important Instructions To Examiners:: Define The Terms: I) Flow Chart Ii) Algorithm
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 1 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Meaning of
„*‟ is a unary operator which returns the value pointed by a pointer ‘*’ 1M
variable.
g) Draw any two symbols used to construct flowchart. Also state 2M
their use. Any two
Ans. correct
symbols and
use : 1M
each
Page 2 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 3 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
2. Runtime: For this loop structures like „for‟ can be used to iterate
through the locations of the array. Here the index of the array starts
with 0 and ends with position one less than the total size of an array.
Eg :
int arr[5];
for(i=0;i<5;i++)
{
scanf(“%d”,&arr[i]);
}
Page 4 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 5 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Example:
Consider str1=”abc” and str2=”abc”
Then strcmp(str1,str2) returns 0 as both the strings are same.
c) Describe scanf() function with its syntax and example. 4M
Ans. scanf() function: It is used to accept input from user during execution Description
of a program. 2M
Syntax 1M
Syntax: scanf("Control string",arg1,arg2,...,argn); Example 1M
control string specifies the field format in which the data is to be
entered. Control string contains conversion character % and a data
type character and optional number specifying the field width. The
arguments arg1,arg2,...,argn specify the address of locations where
the data is stored. Control string and arguments are separated with
comma. It can also have blanks, tabs, or newlines.
Page 6 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Flowchart
Page 7 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 8 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Ans. #include<stdio.h>
#include<conio.h> Correct logic
2M
void main()
{ Correct
int i,j,n; syntax
clrscr(); 2M
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
getch();
}
d) Write a program to declare an array of 5 elements and display 4M
sum of all array elements. Correct logic
Ans. Accepting input from user 2M
#include<stdio.h> Correct
#include<conio.h> syntax 2M
void main()
{
int a[5],i,sum=0;
clrscr();
printf("Enter array elements:");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
for(i=0;i<5;i++)
sum=sum+a[i];
printf("\n Sum= %d",sum);
getch();
}
OR
#include<stdio.h>
#include<conio.h>
void main()
{
Page 9 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 10 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
scanf("%d", &num);
while(num!=0) Correct
Output: 2M
{
res=num%10;
ans=ans*10+res;
num=num/10;
}
printf("Reverse number is %d", ans);
getch();
}
Page 11 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
}
}
printf("\n\nAddition of two matrices is:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d ",c[i][j]);
}
printf("\n");
}
getch();
}
Page 12 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page 13 / 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
else
return(no*factorial(no-1)); Main
function 2M
}
void main()
{
int fact,no;
clrscr();
printf("\n Enter number: ");
scanf("%d",&no);
fact=factorial(no);
printf("\n Factorial number=%d",fact);
getch();
}
c) Write a C program using pointer to read an array of characters 6M
and print them in reverse order.
Accepting
#include<stdio.h> string 1M,
Ans. #include<conio.h> Pointer
void main() initialization
{ 1M,
char str[10],*ptr;
Logic of
int l=0; reverse using
clrscr(); pointer 3M,
printf("Enter string:");
scanf("%s",str); Displaying
ptr=str; reverse string
1M
while(*ptr!='\0')
{
l=l+1;
ptr=ptr+1;
}
while(l>0)
{
ptr=ptr-1;
printf("%c",*ptr);
l=l-1;
}
getch();
}
Page 14 / 14