Vous êtes sur la page 1sur 4

1.

Write a C program to find swapping of two numbers without using third variable
2. Write a C program to find Biggest of two numbers using if else statement
3. The marks obtained by a student in 6 subjects are input through keyboard .the
students gets a division as per the following rules

Percentage Division
Marks
75-100 Distinction
60-74 First class
50-59 Second class
40-49 Third class
0-39 Fail

Write a C program to calculate the division by using else if statement


Solution:
#include<stdio.h>
Void main()
{
int m1, m2, m3, m4,m5,m6,m6,tot;
float per;
printf(“Enter the 6 subjects marks\n”);
scanf(“%d%d%d%d%d%d”,&m1,&m2,&m3,&m4,&m5,&m6);
tot=m1+m2+m3+m4+m5+m6;
per=(tot/600)*100;
if(per>=75)
printf(“Distinction”);
else if(per>=60)
printf(“First class”);
else if(per>=50)
printf(“Second class”);
else if(per>=40)
printf(“Third class”);
else
printf(“Fail”);

}
4. A cloth showroom has announced the following seasonal discounts on purchase
of items
Purchase Discount
Amount(Rs) Mill cloth Handloom items
0-100 - 5.0%
101-200 5.0% 7.5%
201-300 7.5% 10.0%
Above 300 10.0% 15.0%
Write a C program using switch case and else if statements to compute net
amount paid by a customer

Solution:
#include<stdio.h>
#include<conio.h>
void main()
{

int k;
float amount, netamt;
clrscr();
printf(“1.Mill cloth\n”);
printf(“2.Handloom items\n”);
printf(“Enter 1 or 2 \n”);
scanf(“%d”,&k);
printf(“Enter the amount\n”);
scanf(“%f”,&amount);
switch(k)
{
case 1:
if(amount<=100)
netamt=amount;
else if((amount>=101) &&( amount<=200))
netamt=amount*0.95;
else if((amount>=201) &&( amount<=300))
netamt=amount*0.925;
else if(amount>300)
netamt=amount*0.9;

printf(“net amount to be paid by the customer is %8.2f”,netamt);


break;

case 2:
if(amount<=100)
netamt=amount*0.95;
else if((amount>=101) &&( amount<=200))
netamt=amount*0.925;
else if((amount>=201) &&( amount<=300))
netamt=amount*0.9;
else if(amount>300)
netamt=amount*0.85;
printf(“net amount to be paid by the customer is %8.2f”,netamt);
break;

5. Using switch case statement write a C program that takes two operators a,b and one
operator from the user perform the operation and print the answer(Consider operators
+,-,/,*,%)
6. Write a C program to find sum of digits of a given number
7. Write a C program to find reverse of given number using do-while
8. Write a C program to print the following formats
i) 1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
ii) 6 5 4 3 2 1
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
9. Write a C program to find the given string palindrome or not
10. Write a C program to find addition of two matrices using functions
11. Write a C program to find swapping of two numbers using call by value and call by
reference method
12.Write a c program to find product of two matrices using pointes
13.Write a C program to find factorial of a given number using recursion method
14. Write a C program to read student structure and store rollno, name, age, address and
print the details.

Vous aimerez peut-être aussi