Set 1
Set 1
Set 1
calculateSal
Read the question carefully and follow the input and output format.
Karen got salary for this month and she spends 20% of her salary for food and 30% of her salary for
travel. If she takes care of other shifts she will get 2% of the salary per day. Given her salary and the
number of shifts she handled. Calculate how much she can save in her pocket after spending all
these?
First line of input consists of an integer, salary. Next line correspond to the number of shifts. Output
consist of an integer, which is saving.
Include a function named calculateSal(int salary, int shifts) whose return type is an integer, which is
the saving.
Sample Input 1:
7000
Sample Output 1:
4200
Sample Input 2:
8001
Sample Output 2:
*/
#include<stdio.h>
#include<stdlib.h>
int main(){
int salary=0,shifts=0,savings=0;
scanf("%d",&salary);
scanf("%d",&shifts);
if(salary>8000)
else if(shifts<0)
else if(salary<0)
else{
savings = calculateSal(salary,shifts);
printf("%d",savings);
getchar();
getchar();
return 0;
int saving=0;
saving = (salary*0.5)+(salary*0.02*shifts);
return saving;
#include<stdio.h>
#include<stdlib.h>
int findElementCount(int,int[],int);
int main(){
int n=0,flag=0,i,input[20],search=0;
int count=0;
scanf("%d",&n);
if(n<0){
printf("Invalid Input");
getchar();
getchar();
exit(0);
for(i=0;i<n;i++){
scanf("%d",&input[i]);
if(input[i]<0)
flag=1;
if(flag==1){
printf("Invalid Input");
getchar();
getchar();
exit(0);
}
scanf("%d",&search);
count = findElementCount(n,input,search);
printf("%d",count);
getchar();
getchar();
return 0;
int count=0,i;
for(i=0;i<n;i++){
if(array[i]==find)
count++;
return count;
#include<stdio.h>
#include<stdlib.h>
float convertToCentigrade(int);
int main(){
int f=0;
float res=0.0f;
scanf("%d",&f);
if(f<0){
printf("Invalid input");
getchar();
getchar();
exit(0);
res = convertToCentigrade(f);
printf("%0.2f",res);
getchar();
getchar();
return 0;
float centigrade=0.0f;
centigrade = float(fah-32)/9.0f*5;
return centigrade;
#include<stdio.h>
#include<stdlib.h>
int cricketer[20];
int main(){
int n=0,score=0,input[30],i,flag=0;
scanf("%d",&n);
if(n<0){
getchar();
getchar();
exit(0);
}
for(i=0;i<n;i++){
scanf("%d",&input[i]);
if(input[i]<0)
flag=1;
if(flag==1){
printf("Invalid Input");
getchar();
getchar();
exit(0);
scanf("%d",&score);
if(score<0){
printf("Invalid score");
getchar();
getchar();
exit(0);
findCricketerId(input,n,score);
getchar();
return 0;
int i,j=0;
for(i=1;i<size;i=i+1){
if(array[i]>score){
cricketer[j]=array[i-1];
j++;
for(i=0;i<j;i++){
printf("%d\n",cricketer[i]);
getchar();
getchar();
#include<stdio.h>
#include<stdlib.h>
int fedback[30];
void highestFeedBack(int[],int[],int);
int main(){
int size=0,input1[20],input2[20],i=0;
int flag1=0,flag2=0;
scanf("%d",&size);
if(size<0){
getchar();
getchar();
exit(0);
for(i=0;i<size;i++){
scanf("%d",&input1[i]);
if(input1[i]<0)
flag1=1;
for(i=0;i<size;i++){
scanf("%d",&input2[i]);
if(input2[i]<0)
flag2=1;
if(flag1==1 || flag2==1){
printf("Invalid Input");
getchar();
getchar();
exit(0);
highestFeedBack(input1,input2,size);
return 0;
int i=0,j=0,k=0,count=0,count1=0;
for(i=0;i<size;i=i+2){
count=0;
for(j=0;j<size;j=j+2){
if(metlife[i]==hardfort[j]){
count=1;
if(metlife[i+1]>hardfort[j+1]){
fedback[k]=metlife[i];
fedback[++k]=metlife[i+1];
k++;
else{
fedback[k]=metlife[i];
fedback[++k]=hardfort[j+1];
k++;
if(count==0){
fedback[k]=metlife[i];
fedback[++k]=metlife[i+1];
k++;
for(i=0;i<size;i=i+2){
count1=0;
for(j=0;j<size;j=j+2){
if(hardfort[i]==metlife[j]){
count1=1;
if(count1!=1){
fedback[k]=hardfort[i];
fedback[++k]=hardfort[i+1];
k++;
}
for(i=0;i<k;i++){
printf("%d\n",fedback[i]);
getchar();
getchar();
#include<stdio.h>
#include<stdlib.h>
int maximumSum(int[],int);
int main(){
int n=0,i,flag=0,input[20],max=0;
scanf("%d",&n);
if(n<0){
getchar();
getchar();
exit(0);
for(i=0;i<n;i++){
scanf("%d",&input[i]);
if(input[i]<0)
flag=1;
}
if(flag==1){
printf("Invalid input");
getchar();
getchar();
exit(0);
max = maximumSum(input,n);
printf("%d",max);
getchar();
getchar();
return 0;
int i=0,max=0,evensum=0,oddsum=0;
for(i=0;i<size;i++){
if(numbers[i]%2==0)
else
if(evensum>oddsum)
max = evensum;
else
max=oddsum;
return max;
}
#include<stdio.h>
#include<stdlib.h>
int main(){
int number=0,result;
scanf("%d",&number);
if(number<0)
else if(number>32767)
else{
result=powerOfTwo(number);
if(result==1)
printf("yes");
else
printf("No");
getchar();
getchar();
return 0;
int result=0;
n /= 2;
return (n == 1);
}
#include<stdio.h>
#include<stdlib.h>
int main(){
int n=0,flag=0,i,input[30];
int avg=0;
scanf("%d",&n);
if(n<0){
getchar();
getchar();
exit(0);
for(i=1;i<=n;i++){
scanf("%d",&input[i]);
if(input[i]<0)
flag=1;
if(flag==1){
printf("Invalid Input");
getchar();
getchar();
exit(0);
avg = primeIndexSum(input,n);
printf("%d",avg);
getchar();
getchar();
return 0;
int sum=0,i,j=0,count=0,temp=0,avg=0;
for(i=2;i<=size;i++){
count=0;
for(j=1;j<=i;j++){
if(i%j==0)
count++;
if(count==2){
sum = sum+array[i];
temp++;
else
continue;
avg=sum/temp;
return avg;
#include<stdio.h>
#include<stdlib.h>
int productDigits(int);
int main(){
int n=0,result=0;
scanf("%d",&n);
result = productDigits(n);
if(result==-1)
printf("Invalid Input");
else
printf("%d",result);
getchar();
getchar();
return 0;
int num=1;
if((number<0) || (number>32767))
res = -1;
else{
while(number!=0){
num=num*(number%10);
number = number/10;
res = num;
return res;
/*
Include a function named countRepeaters that accepts 2 arguments and returns an int. The first
argument is the input array and the second argument is an int that corresponds to the size of the
array. The function returns an int that corresponds to the number of repeaters.
If the size of the array is negative or if any of the array elements are negative, print “Invalid Input”
and terminate the program.
Input consists of n+1 integers. The first integer corresponds to n, the number of elements in the
array. The next 'n' integers correspond to the elements in the array.
Sample Input 1:
1000
2000
3500
2000
5000
Sample Output 1:
2
Sample Input 2:
-5
Sample Output 2:
Invalid Input
Sample Input 3:
1000
-2000
Sample Output 3:
Invalid Input
*/
#include<stdio.h>
#include<stdlib.h>
int countRepeaters(int[],int);
int main(){
int n=0,input[20]={0},i,flag=0,No_of_elements=0;
scanf("%d",&n);
if(n<0){
printf("Invalid input");
getchar();
getchar();
exit(0);
}
for(i=0;i<n;i++){
scanf("%d",&input[i]);
if(input[i]<0)
flag=1;
if(flag==1){
printf("Invalid input");
getchar();
getchar();
exit(0);
No_of_elements = countRepeaters(input,n);
printf("%d",No_of_elements);
getchar();
getchar();
return 0;
int elements_count=1,i,j,out[20],k=0;
for(i=0;i<size;i++){
for(j=i+1;j<size;){
if(in[i]==in[j]){
elements_count++;
for(k=j;k<size;k++)
in[k]=in[k+1];
size--;
}
else
j++;
return elements_count;