CTS Coding Questions

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

CTS CODING QUESTIONS

1. #include<stdio.h>

int main()

int l;

printf("enter the no of liters to fill the tank :");

scanf("%d",&l);

double lt=(l*1.00);

if(lt<1)

printf("invalid input");

exit(0);

int d;

printf("enter the distance covered :");

scanf("%d",&d);

double dt=(d*1.00);

if(dt<1)

printf("invalid input");

exit(0);

double lk=(lt/dt)*100;

printf("liters/100 km :");

printf("%.2f\n",lk);

double z=dt*0.6214;

double x=lt*0.2642;

double y=(z/x);

printf("miles/gallons :");

printf("%.2f",y);

}
2. #include<stdio.h>

int main()

int p;

printf("Enter the number of pizzas bought :");

scanf("%d",&p);

int pu;

printf("Enter the number of puffs you bought :");

scanf("%d",&pu);

int c;

printf("Enter the number of cool drinks you bought :");

scanf("%d",&c);

printf("Bill Details :\n");

printf("No of pizzas : %d\n",p);

printf("No of puffs : %d\n",pu);

printf("No of cool drinks : %d\n",c);

int tp= (p*100)+(pu*20)+(c*10);

printf("The total price : %d\n",tp);

printf("ENJOY THE SHOW !");

3. #include<stdio.h>

int main()

int n1,n2,n3,n4;

printf("Enter the number of digits :\n");

scanf("%d %d %d %d",&n1,&n2,&n3,&n4);

printf("%d - %c\n",n1,n1);

printf("%d - %c\n",n2,n2);

printf("%d - %c\n",n3,n3);

printf("%d - %c\n",n4,n4);

}
4. #include<stdio.h>

int main()

int d;

printf("Enter the month :");

scanf("%d",&d);

switch(d)

case 12:

case 1:

case 2:

printf("Season : Winter");

break;

case 4:

case 5:

case 6:

printf("Season : Spring");

break;

case 7:

case 8:

case 9:

printf("Season : Summer");

break;

case 10:

case 11:

printf("Season : Autumn");

break;

default:

printf("invalid month");

}
5. #include<stdio.h>

int main()

int n;

scanf("%d",&n);

if(n==0)

printf("no factors");

else if(n>0)

for(int i=1;i<=n;i++)

if(n%i==0)

printf("%d ",i);

else if(n<0)

n=n*-1;

for(int i=1;i<=n;i++)

if(n%i==0)

printf(",%d",i);

}
6. #include<stdio.h>

int main()

int n,sum=0,r;

scanf("%d",&n);

int temp=n;

while(n>0)

r=n%10;

sum=sum*10+r;

n/=10;

if(temp==sum)

printf("yes");

else

printf("no");

7. #include<stdio.h>

int main()

int c;

printf("enter the no of students placed in csc :");

scanf("%d",&c);

int m;

printf("enter the no of students placed in mech :");

scanf("%d",&m);

int e;

printf("enter the no of students placed in ece : ");

scanf("%d",&e);

if(c<0 || e<0 || m<0)

printf("Invalid input");
else if(c==m && m==e && e==c)

printf("None of the department has got the highest placement");

else if(c==m && c>e)

printf("The highest placement is \n");

printf("CSC\n");

printf("MECH");

else if(m==e && m>c)

printf("The highets placed is \n");

printf("MECH\n");

printf("ECE");

else if(e==c && e>m)

printf("The highest placed is \n");

printf("ECE\n");

printf("CSC");

else if(c>m && c>e)

printf("The highest placement is \n");

printf("CSC");

else if(m>c && m>e)

printf("The highets placed is \n");

printf("MECH");

else
{

printf("The highest placed is \n");

printf("ECE");

8. #include<stdio.h>

int main()

float s;

printf("Enter the salary :");

scanf("%f",&s);

float p;

printf("Enter the performance appraisal rate :");

scanf("%f",&p);

if(s<0 || p>=1 || p<=5)

printf("Invalid input");

else if(p>=1 && p<=3)

s=s+s/100*10;

printf("%.2f",s);

else if(p>=3.1 && p<=4)

s=s+s/100*25;

printf("%.2f",s);

else if(p>=4.1 && p<=5)

s=s+s/100*30;

printf("%.2f",s);

}}
9. #include<stdio.h>

int main()

int n,m,sum=0;

printf("Enter your car number :");

scanf("%d",&n);

if(n<1000 || n>9999)

printf("invalid number");

else

while(n!=0)

m=n%10;

sum+=m;

n/=10;

if(sum%3==0 || sum%5==0 || sum%7==0)

printf("Lucky number");

else

printf("Not a Lucky number");

10.

You might also like