0% found this document useful (0 votes)
16 views5 pages

Group A CIA 1 Theory Ans - Key

The document outlines the first CIA test for the CSE101 course on Problem Solving and Programming in C, conducted in December 2020. It includes a series of programming questions and exercises, covering topics such as syntax for the scanf function, control structures, and functions in C. The test is divided into two parts, with Part A consisting of short answer questions and Part B requiring the writing of complete C programs.

Uploaded by

shahsham005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views5 pages

Group A CIA 1 Theory Ans - Key

The document outlines the first CIA test for the CSE101 course on Problem Solving and Programming in C, conducted in December 2020. It includes a series of programming questions and exercises, covering topics such as syntax for the scanf function, control structures, and functions in C. The test is divided into two parts, with Part A consisting of short answer questions and Part B requiring the writing of complete C programs.

Uploaded by

shahsham005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

School of Computing

First CIA Test – December 2020


Course Code: CSE101
Course Name: Problem Solving and Programming in C
Yr. & Programme: I Year - I Sem
Duration: 45 minutes Max Marks: 25_
PART A 5 x 2 = 10 Marks
Answer all the Questions
S.NO Questions And Answer Key CO RBT

What is the syntax of scanf function and also write the scanf statement to r 1 II
ead the input as “SASTRA UNIVERSITY THANJVUR” [ Note: In input the
re should be spaces between the words]

Answer

1. Syntax
scanf("<format specifier>" , <address of variable>);
For reading input as “SASTRA UNIVERSITY THANJAVUR”
char a[100];
scanf("%[^\n]",a);

Fill up the appropriate executable statement in the following program (in 2 III
the given blanks) in order to get the output as

Value of i=0
Value of i=2
Value of i=4
Value of i=6
Main Ends

#include<stdio.h>
int main()
2.
{
int i=0;
do
{
printf("Value of i=%d \n",i);
------------- ;//statement 1
if(---------)//statement 2
break;
}while(i<=10);
printf("Main Ends");
}
}

Answer

Statement 1-> i=i+2


Statement 2-> i>6 or i>=7 or i==8

School management wants to start their admission for lower kinder garden 1 III
class. But they want to give the admission to the child whose age is equal to
three. Write a program to read the age and determine whether child will
get the admission or not by using ternary operator.
Answer

#include<stdio.h>
int main()
3.
{
int age;
scanf("%d",&age);
age==3? printf(" get Admission") : printf(" no Admission");

Fill up the appropriate executable statement in the following program (in 2 II


the given blanks) in order to get the output as

SASTRA University Thanjavur

#include<stdio.h>
void fun1();
void fun2();
void fun3();
4. int main()
{
----------;//statement 1
}
void fun1()
{
printf("University ");
-----------; // statement 2

}
void fun2()
{
printf("SASTRA ");
---------; // statement 3
}
void fun3()
{
printf("Thanjavur");
}

Answer
Statement1 => fun2()
Statement2 => fun1()
Statement 3 => fun3()
5. Fill up the blanks with appropriate operator to form valid expression 1 II
(a) 5 ---2--- 5 (use *, / opearator in appropriate places to have output 10)
(b) 5 ---2 ---5 ( use +,- opearator in appropriate places to have output 8)

Answer

5/2*5
5-2+5

PART B 3 x 5 = 15 Marks
Answer all the Questions
S.NO Questions CO RBT

Write a C program to accept an employee code and basic salary(Bs). Calculate 2 IV


net salary by adding HRA and DA to basic salary. If Net salary is greater than
or equal to ten thousand then display the string “WELCOME MANAGER”
along with their details. If Net salary is greater than or equal to five thousand,
then display the string “WELCOME CLERK” along with their details.
Otherwise display the string “WELCOME EMPLOYEE” along their details.
[Note: HRA=10% of BS
DA=90% of BS Netsal=BS+HRA+DA]
Answer
#include<stdio.h>
6. void main()
{
int ecode,bs;
float hra,da,net;

printf("enter employee code and basic salary:\t");


scanf("%d%d",&ecode,&bs);

hra= bs*(10/100.0);
da=bs*(90/100.0);
net=bs+hra+da;
if(net>=10000)
{
printf("\n welcome manager");
}
else if(net>=5000 )
{
printf("\n......... Welcome clerk.............");
}
else printf("\n Welcome Employee");
printf("\n...........Emplyee salary details .......\n");
printf("\nDa=%f",da);
printf("\nhra=%f",hra);
printf("\nnet=%f",net);
}

Write a C program to find the sum for the given integer in the following 2 III
format. (if n=123) Sum=1 5 + 25 +35
Answer

1. #include<stdio.h>
#include<math.h>
void main()
{
int i,n,rem,n1;
long sum=0;
7 printf("enter n value :\t");
scanf("%d",&n);
while(n>0)
{
rem=n%10;
n=n/10;
sum=sum+pow(rem,5);
}
printf("sum of digit to the power of 5=%ld",sum);
}

Design a C program to find the sum of following series using function concept. 2 III
S= 1/1! + 5/5! +9/9! +13/13!............
Answer

#include<stdio.h>
8 #include<math.h>
int fact(int);
void main()
{
int n,i,res;
float sum=0;
printf("enter n value:\t");
scanf("%d",&n);
for(i=1;i<=n; i+=4)
{
res=fact(i);
sum=sum+((float)i/res);
}
printf("series sum=%f",sum);
}

int fact(int m)
{
int f=1,j;

for(j=1;j<=m;j++)
{
f=f*j;
}
return(f);
}

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