Group A CIA 1 Theory Ans - Key
Group A CIA 1 Theory Ans - Key
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
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");
#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
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);
}