Вы находитесь на странице: 1из 21

1. Write a program to convert a length from kilometers to meters. 2.

Write a program to divide an integer by another integer and find the quotient and remainder. 3. Write a program to convert entered number of days into years, months and days. 4. Write a program to convert seconds to hours, minutes and seconds and print them one below the other. or e!ample if 3"# seconds is given, the output must be $ % hours " minutes "#seconds ". Write a program to read the principal, rate of interest and number of years and find the simple interest using the formula simple interest&pnr'1%%. (. )f a cube has its side and its volume and surface area given by the formulae v & a 3 and s&(a2. Write a program to read *a+ and print the volume and surface area. #. ,he area of a triangle is given by the formula area &1'2 base *height. Write a program to read base and height and print the area. -. Write a program to find the area of a circle.a&22'#/r20 1. Write a program to find the volume of the cylinder. .v&22'#/r2h0 1%. Write a program to convert a temperature reading in degree ahrenheit to degree 2elsius using the formula$ 2& ."'10/.f3320. 11. Write a program to input an arbitrary number and find out whether it is positive, or negative. 12. Write a program to decide whether there is gain or loss4 when cost price .250 and selling price .650 of items are given. 13. Write a program to input any three integer numbers and display the largest number. 14. Write a program to calculate area of a circle, a rectangle or a triangle depending upon user+s choice. 1". Write a program to enter the day, month and year of the date of birth of a person and the day, month and year of today and find the age of the person in years, months and days. 1(. Write a program to enter marks for 7nglish, 8otel management, 9arketing, :ccountancy and 2omputer. 2alculate total and percentage. ind the division. 1#. Write a program to display the multiplication table of an entered number. 1-. Write a c program to print ibonacci series i.e.% 1 1 2 3 " -;.. up to the nth term 11. Write a program to check whether the given number is palindrome or not. 2%. Write a program to find factorial of a given positive number. 21. Write a 2 program to input an integer and check whether it is 5rime or not. 22. or any integer input through the keyboard, write a 2 program to find out whether it is an odd number or even number. .867<32%(20 23. Write a program to display the name of the day in a week, depending on the number entered through the keyboard using the switch3case statement. 24. Write a program to reverse a number 2". Write a program to find the sum of the series$ 1'12=1'22=1'32=;..1'n2. 2(. Write a program to input an integer numbers and find the highest number among them. 2#. Write a *2+ program to store n numbers in an array and find the smallest number among them. 2-. Write a program to input a string and count the number of vowels containing in the string. 21. Write a 2 program to input the ages of *n+ students and count the number of students who has the age in between 1#311. 3%. Write a *2+ program to store a string and determine whether it is palindrome or not. 31. Write a *2+ program to find the sum of first *n+ natural numbers using recursive function. 32. Write a *2+ program to find the factorial of a number using recursive function. 33. : man is paid at the hourly rate of >s."%'3per hour for the first 3% hours worked in a week. ,here after the overtime is paid at 1." times the hourly rate for the ne!t time 2" hours and 2 times the hourly rate for further hours worked. )nput the number of hours worked in a week and print weekly wages. 34. Write a program to store marks of *n+ students of a class in single dimensional array and find highest, lowest and average mark of the class and also count the number of students who obtained marks greater than (%. 3". Write a program to generate ibonacci series up to nth terms using recursive function. 3(. Write a program to stone *n+ numbers in an array and sort them in ascending order.
C Solutions , 1

3#. Write a 2 program to calculate the factorial of given number *n+. ,he rules for calculating are if n?% calculate factorial, factorial&1, if n&% and if n@%, display the error message. 3-. Aational book center decides to prepare a <ook 2lub. 9embers of the club are entitled to special discounts on the purchase of the book. ,he discount of 1"B is given to the members if purchase amount e!ceeds "%%% and 1%B is given it don+t e!ceed. Aon members aren+t normally given any discount. 8owever if their purchase e!ceeds >s. "%%%, a discount of #B is given. Write a 2 program to analyCe the above problem and find the net purchase amount. 31. Write a program to convert the line of lowercase te!t to uppercase te!t. 4%. Write a program to print integers from 1 to 1%% using W8)D7 loop 41. Write a program to calculate and print square of any given number. 42. Write a 2 program to display the sum of *n+ terms of even numbers. .867<32%(30 43. Write a 2 program to calculate the factorial of a given number using function. .867<3 2%(30 44. Write a 2 program to print the first 1% terms of the following series using E> loop. 1, ", 1, 13, ;;.. .867<32%(30 4". Write a 2 program to sort integer values in descending order. .867<32%(30 4(. Write a 2 program to read the age of 4% students and count the number of students of the age between 1" and 2". .867<32%(30 4#. Write a 2 program to print the 1% positive integers and their factorials. .867<32%(20 4-. Write a 2 program to input *n+ numbers and find out greatest and smallest number. .867<32%(20 41. Write a 2 program to read in a positive integer less than 2% and display its multiplication table. .867<32%(20 "%. Write a 2 program to input the names of *n+ numbers of students and sort them in alphabetical order. .867<32%(20 "1. Write a 2 program to read salaries of 2%% employees and count the number of employees getting salary between "%%% 3 1%%%%. .867<32%(20 "2. Write a 2 program that will read successive records from the data file and display each record on the screen in an appropriate format. .867<32%(2,2%(10 "3. Write a 2 program that reads different names and addresses into the computer and rearrange the names into alphabetical order using the structure variable. .867<3 2%(10 "4. Write a 2 program to display the multiplication table of series of given numbers entered by the user. .867<32%(10 "". Write a program using 2 language to read the age of 1%% persons and count the number of persons in the age group between "% and (%. Fse the * or+ and *2ontinue+ statements. .867<32%(10 "(. Write a 2 program to input a string and count the no of vowels in the string. "#. Write a 2 program to write the name, address and telno in a data file and read the successive records to display them in the proper format. "-. Write a 2 program to write *n+ person+s name, address and telno in a data file and display them, reading the successive data from the file in proper forma

C Solutions ,

1. Write a program to convert a length from kilometers to meters.


Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int km, m4 clrscr.04 printf.I7nter the Jilometer$I04 scanf.IBdI,Kkm04 m&km/1%%%4 printf.I,he length in meter&BdI,m04 getch.04 L

2. Write a program to divide an integer by another integer and find the quotient and remainder.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int a,b,quo,rem4 clrscr.04 printf.I7nter two numbers aKb$I04 scanf.IBdBdI,Ka,Kb04 quo&a'b4 rem&aBb4 printf.IMuotient&BdI,quo04 printf.INn>emainder&BdI,rem04 getch.04 L

3. Write a program to convert entered number of days into years, months and days.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int d,year,month,day,remd4 clrscr.04 printf.I7nter the number of days to convert$I04 scanf.IBdI,Kd04 year&d'3("4 remd&dB3("4 month&remd'3%4 day&remdB3%4 printf.IOear&BdNn9onth&BdNnPay&BdI,year,month,day04 getch.04 L

4. Write a program to convert seconds to hours, minutes and seconds and print them one below the other. or e!ample if 3"# seconds is given, the output must be $ % hours " minutes "#seconds
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int s,hour,min,sec,rems4 clrscr.04 printf.I7nter the seconds to convert$I04 scanf.IBdI,Ks04 hour&s'3(%%4 rems&sB3(%%4 min&rems'(%4 sec&remsB(%4 printf.I8our&BdNn9inutes&BdNn6econds&BdI,hour,min,sec04 getch.04 L

". Write a program to read the principal, rate of interest and number of years and find the simple interest using the formula simple interest&pnr'1%%.
Ginclude @stdio.h? Ginclude @conio.h? C Solutions , 3

void main.0 H )nt p,r,n,)4 clrscr.04 printf.Q7nter the 5rinciple, >ate and ,ime$R04 scanf.QBdBdBdR,Kp,Kr,Kn04 i&.p/n/r0'1%%4 printf.Q)nterest&BdR,i04 getch.04 L

(. )f a cube has its side and its volume and surface area given by the formulae v & a3 and s&(a2. Write a program to read *a+ and print the volume and surface area.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int a,v,s4 clrscr.04 printf.Q7nter the value of a$R04 scanf.QBdR,Ka04 v&a/a/a4 s&(/a/a4 printf.QSolume&BdNn6urface area&BdR,v,s04 getch.04 L

#. ,he area of a triangle is given by the formula area &1'2 base *height. Write a program to read base and height and print the area.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int base,height4 float area4 clrscr.04 printf.Q7nter the base and height$R04 scanf.QBdBdR,Kbase,Kheight04 area&.1'20/base/height4 printf.Q:rea of the traingle&BfR,area04 getch.04 L

-. Write a program to find the area of a circle.a&22'#/r20


Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int r4 float area4 clrscr.04 printf.Q7nter the radius of the circle$R04 scanf.QBdR,Kr04 area&.22'#0/r/r4 printf.Q:rea of the 2ircle&BfR,area04 getch.04 L

1. Write a program to find the volume of the cylinder. .v&22'#/r2h0.


Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int r,h4 float volume4 clrscr.04 printf.Q7nter the radius and height of the cylinder$R04 scanf.QBdBdR,Kr,Kh04 volume&.22'#0/r/r/h4 printf.QSolume of the 2ylinder&BfR,volume04 getch.04 L C Solutions , 4

1%. Write a program to convert a temperature reading in degree ahrenheit to degree 2elsius using the formula$ 2&."'10/.f3320.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int f4 float c4 clrscr.04 printf.Q7nter the temperature in ahrenheit$R04 scanf.QBdR,Kf04 c&."'10/.f33204 printf.Q,emperature in 2elsius&BfR,c04 getch.04 L

11. Write a program to input an arbitrary number and find out whether it is positive, or negative.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int n4 clrscr.04 printf.Q7nter any number .7ither positive or negative0$R04 scanf.QBdR,Kn04 if.n@%0 printf.Q,he entered number is negativeR04 else printf.Q,he entered number is positiveR04 getch.04 L

12. Write a program to decide whether there is gain or loss4 when cost price .250 and selling price .650 of items are given.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int cp,sp4 clrscr.04 printf.Q7nter the cost price.cp0 and selling price .sp0$R04 scanf.QBdBdR,Kcp,Ksp04 if.sp?cp0 printf.QT:)AR04 else printf.QDE66R04 getch.04 L

13. Write a program to input any three integer numbers and display the greatest number. .867<32%(40
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int a,b,c4 clrscr.04 printf.Q7nter the numbers a, b and c$R04 scanf.QBdBdBdR,Ka,Kb,Kc04 if.a?b KK a?c0 printf.Q: is the largest numberR04 else if.b?a KK b?c0 printf.Q< is the largest numberR04 else printf.Q2 is the largest number$R04 getch.04 L

14. Write a program to calculate area of a circle, a rectangle or a triangle depending upon user+s choice.
C Solutions , 5

Ginclude @stdio.h? Ginclude @conio.h? void main.0 H char ch4 int r,l,b,base,h4 float area4 clrscr.04 printf.I7nter the choice, UcU for circle, UrU for rectangle or UtU for triangle$I04 scanf.IBcI,Kch04 switch.ch0 H case UcU$ printf.I7nter the radius$I04 scanf.IBdI,Kr04 area&.3.14/r/r04 printf.I:rea of the circle&BfI,area04 break4 case UrU$ printf.I7nter the length$I04 scanf.IBdI,Kl04 printf.I7nter the breadth$I04 scanf.IBdI,Kb04 area&l/b4 printf.I:rea of the rectangle&BfI,area04 break4 case UtU$ printf.I7nter the base$I04 scanf.IBdI,Kbase04 printf.I7nter the height$I04 scanf.IBdI,Kh04 area&.%."/base/h04 printf.I:rea of the triangle&BfI,area04 break4 default$ printf.I7nter the valid choice, either c,t or r$I04 break4 L getch.04 L

1". Write a program to enter the day, month and year of the date of birth of a person and the day, month and year of today and find the age of the person in years, months and days.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int td,tm,ty,bd,bm,by,y,rd,m,d,ttd,btd,diff4 clrscr.04 printf.I7nter your birth date,month,year$I04 scanf.IBdBdBdI,Kbd,Kbm,Kby04 printf.I7nter todays date,month,year$I04 scanf.IBdBdBdI,Ktd,Ktm,Kty04 ttd&ty/3("=tm/3%=td4 btd&by/3("=bm/3%=bd4 diff&ttd3btd4 y&diff'3("4 rd&diffB3("4 m&rd'3%4 d&rdB3%4 printf.IOour :ge&Bd Oear Bd 9onth Bd PayI,y,m,d04 getch.04 L

1(. Write a program to enter marks for 7nglish, 8otel management, 9arketing, :ccountancy and 2omputer. 2alculate total and percentage. ind the division.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 C Solutions , 6

H int acc,comp,hm,mkt,eng,total4 float per4 clrscr.04 printf.I7nter the marks of account$I04 scanf.IBdI,Kacc04 printf.INn7nter the marks of 2omputer$I04 scanf.IBdI,Kcomp04 printf.INn7nter the marks of 8otel 9gmt$I04 scanf.IBdI,Khm04 printf.INn7nter the marks of 9arketing$I04 scanf.IBdI,Kmkt04 printf.INn7nter the marks of 7nglish$I04 scanf.IBdI,Keng04 total&acc=comp=hm=mkt=eng4 printf.INn,otal&BdI,total04 per&total'"4 printf.INn5ercentage&BfI,per04 if.per?&#"0 printf.INnPivision&PistinctionI04 else if.per?&(%0 printf.INnPivision& irst PivisionI04 else if.per?&4"0 printf.INnPivision&6econd PivisionI04 else printf.INnPivision&,hird PivisionI04 getch.04 L

1#. Write a program to display the multiplication table of an entered number.


Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int n,i4 clrscr.04 printf.I7nter a number$I04 scanf.IBdI,Kn04 for.i&14i@&1%4i==0 H printf.IBd/Bd&BdNnI,n,i,n/i04 L getch.04 L

1-. Write a c program to print ibonacci series i.e.% 1 1 2 3 " -;.. upto nth term.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int a&%,b&1,c,n,i4 clrscr.04 printf.I7nter how many numnbers$I04 scanf.IBdI,Kn04 printf.IBd,BdI,a,b04 for.i&%4i@n324i==0 H c&a=b4 printf.I,BdI,c04 a&b4 b&c4 L getch.04 L

11. Write a program to check whether the given number is palindrome or not.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int n,rev&%,digit,num4 clrscr.04 C Solutions ,

printf.I7nter a number$I04 scanf.IBdI,Kn04 num&n4 while .nV&%0 H digit&nB1%4 rev&rev/1%=digit4 n&n'1%4 L if.rev&&num0 printf.I,he number is pallindromeI04 else printf.I,he number is not a pallindromeI04 getch.04 L

2%. Write a program to find factorial of a given positive number.


Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int n,fact,i4 clrscr.04 printf.I7nter the numberI04 scanf.IBdI,Kn04 fact&14 if.n@%0 printf.I actorial of negative number is not possibleI04 else H for.i&n4i?%4i330 H fact&fact/i4 L printf.I actorial&BdI,fact04 L getch.04 L

21. Write a 2 program to input an integer and check whether it is 5rime or not.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int n,i4 clrscr.04 printf.I7nter a number$I04 scanf.IBdI,Kn04 for.i&24i@&n'24i==0 H if.nBi&&%0 H printf.I,he number is not a prime number$I04 getch.04 e!it.%04 L L printf.I,he number is a prime numberI04 getch.04 L

22. or any integer input through the keyboard, write a 2 program to find out whether it is an odd number of even number. .867<32%(20
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int num4 clrscr.04 printf.Q7nter a numberR04 C Solutions , 8

scanf.QBdR,Knum04 if.numB2&&%0 printf.Q7venR04 else printf.QEddR04 getch.04 L

23. Write a program to display the name of the day in a week, depending on the number entered through the keyboard using the switch3case statement.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int ch4 clrscr.04 printf.I7nter a number .13#0 to display the name of the day$I04 scanf.IBdI,Kch04 switch.ch0 H case 1$ printf.I6undayI04 break4 case 2$ printf.I9ondayI04 break4 case 3$ printf.I,uesdayI04 break4 case 4$ printf.IWednesdayI04 break4 case "$ printf.I,hursdayI04 break4 case ($ printf.I ridayI04 break4 case #$ printf.I6aturdayI04 break4 default$ printf.I7nter the valid choice between 13#I04 break4 L getch.04 L

24. Write a program to reverse a number. . 867< 32%(40


Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int n,rev&%,digit4 clrscr.04 printf.I7nter a number$I04 scanf.IBdI,Kn04 while .nV&%0 H digit&nB1%4 rev&rev/1%=digit4 n&n'1%4 L printf.I>everse number&BdI,rev04 getch.04 L

2". Write a program to find the sum of the series$ 1'12=1'22=1'32=;..1'n2.


Ginclude @stdio.h? Ginclude @conio.h? void main.0 C Solutions , 9

H int n,i4 float sum&%.%4 clrscr.04 printf.I7nter the last number$I04 scanf.IBdI,Kn04 for.i&14i@&n4i==0 H sum&sum=.1'float.i/i004 L printf.I6um&BfI,sum04 getch.04 L

2(. Write a program to input an integer numbers and find the highest number among them.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int numW1%%X,n,highest,i4 clrscr.04 printf.I7nter the value of nI04 scanf.IBdI,Kn04 for.i&%4i@n4i==0 H printf.I7nter the numbersI04 scanf.IBdI,KnumWiX04 L highest&numW%X4 for.i&%4i@n4i==0 H if.numWiX?highest0 highest&numWiX4 L printf.I,he highest number&BdI,highest04 getch.04 L

2#. Write a *2+ program to store n numbers in an array and find the smallest number among them.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int numW1%%X,n,smallest,i4 clrscr.04 printf.I7nter the value of nI04 scanf.IBdI,Kn04 for.i&%4i@n4i==0 H printf.I7nter the numbersI04 scanf.IBdI,KnumWiX04 L smallest&numW%X4 for.i&%4i@n4i==0 H if.numWiX@smallest0 smallest&numWiX4 L printf.I,he smallest number&BdI,smallest04 getch.04 L

2-. Write a program to input a string and count the number of vowels containing in the string.
Ginclude @stdio.h? Ginclude @conio.h? Ginclude @string.h? void main.0 H C Solutions , 10

char stringW1%%X4 int i, l, count&%4 clrscr.04 printf.I7nter a 6tringI04 scanf.IBsI,string04 l&strlen.string04 for.i&%4i@l4i==0 H if.stringWiX&&UaUYYstringWiX&&U:UYYstringWiX&&UeUYY stringWiX&&U7UYYstringWiX&&UiUYYstringWiX&&U)UYY stringWiX&&UoUYYstringWiX&&UEUYYstringWiX&&UuUYY stringWiX&&UFU0 count&count=14 L printf.IAo of Sowels &BdI,count04 getch.04 L

21. Write a 2 program to input the ages of *n+ students and count the number of students who has the age in between 1#311.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int i,n,count&%,ageW1%%X4 clrscr.04 printf.I7nter the value of n$I04 scanf.IBdI,Kn04 for.i&%4i@n4i==0 H printf.I7nter the age of studentI04 scanf.IBdI,KageWiX04 L for.i&%4i@n4i==0 H if.ageWiX?&1# KK ageWiX@&110 count&count=14 L printf.IAo of students having age in between 1# to 11 &BdI,count04 getch.04 L

3%. Write a *2+ program to store a string and determine whether it is palindrome or not.
Ginclude @stdio.h? Ginclude @conio.h? Ginclude @string.h? void main.0 H char stringW3%X4 int i,l,Z4 clrscr.04 printf.I7nter a string$I04 scanf.IBsI,string04 l&strlen.string04 for.i&%,Z&l314i@l'24i==,Z330 H if.stringWiXV&stringWZX0 H printf.IAot a 5allindromeI04 getch.04 e!it.%04 L L printf.I5allindromeI04 getch.04 L

31. Write a *2+ program to find the sum of first *n+ natural numbers using recursive function.
Ginclude @stdio.h? Ginclude @conio.h? C Solutions , 11

int add.int04 void main.0 H int n4 clrscr.04 printf.I7nter how many numbers$I04 scanf.IBdI,Kn04 printf.I6um of n natural numbers&BdI,add.n004 getch.04 L int add.int n0 H if.n&&%0 return %4 else return.n=add.n31004 L

32. Write a *2+ program to find the factorial of a number using recursive function.
Ginclude @stdio.h? Ginclude @conio.h? int factorial.int04 void main.0 H int n4 clrscr.04 printf.I7nter a numbers$I04 scanf.IBdI,Kn04 printf.I actorail&BdI,factorial.n004 getch.04 L int factorial.int n0 H if.n@&10 return 14 else return.n/factorial.n31004 L

33. : man is paid at the hourly rate of >s."%'3per hour for the first 3% hours worked in a week. ,here after the overtime is paid at 1." times the hourly rate for the ne!t time 2" hours and 2 times the hourly rate for further hours worked. )nput the number of hours worked in a week and print weekly wages.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int hr,w4 float tw4 w&"%4 clrscr.04 printf.I7nter the hours worked$I04 scanf.IBdI,Khr04 if.hr@&3%0 tw&hr/w4 else if.hr@&""0 tw&.3%/w0=..hr33%0/w/1."04 else tw&.3%/w0=.2"/w/20=..hr3""0/w/204 printf.I,otal Wages&>s.BfI,tw04 getch.04 L

34. Write a program to store marks of *n+ students of a class in single dimensional array and find highest, lowest and average mark of the class and also count the number of students who obtained marks greater than (%.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 C Solutions , 12

H int marksW1%%X,n,highest,lowest,sum&%,count&%,i4 float average4 clrscr.04 printf.I7nter how many students$I04 scanf.IBdI,Kn04 for.i&%4i@n4i==0 H printf.I7nter the marks$I04 scanf.IBdI,KmarksWiX04 L highest&marksW%X4 for.i&%4i@n4i==0 H if.highest@marksWiX0 highest&marksWiX4 L printf.INn8ighest marks&BdI,highest04 lowest&marksW%X4 for.i&%4i@n4i==0 H if.lowest?marksWiX0 lowest&marksWiX4 L for.i&%4i@n4i==0 H sum&sum=marksWiX4 L average&sum'n4 printf.INn:verage marks&BfI,average04 printf.INnDowest marks&BdI,lowest04 for.i&%4i@n4i==0 H if.marksWiX?(%0 count&count=14 L printf.INnAo. of 6tudents getting marks more than (%&BdI,count04 getch.04 L

3". Write a program to generate ibonacci series up to nth terms using recursive function.
Ginclude @stdio.h? Ginclude @conio.h? int fibonacci.int,int,int04 void main.0 H int n,a&%,b&14 clrscr.04 printf.I7nter how many numbers$I04 scanf.IBdI,Kn04 fibonacci.a,b,n04 getch.04 L int fibonacci.int a,int b,int n0 H int c4 if.n&&%0 return %4 else H c&a=b4 a&b4 b&c4 printf.INtBdI,c04 fibonacci.a,b,n3104 L L

3(. Write a program to stone *n+ numbers in an array and sort them in ascending order.
Ginclude @stdio.h? C Solutions , 13

Ginclude @conio.h? void main.0 H int i,Z,numW1%%X,n,temp4 clrscr.04 printf.I7nter how many numbers$I04 scanf.IBdI,Kn04 for.i&%4i@n4i==0 H printf.I7nter the number$I04 scanf.IBdI,KnumWiX04 L for.i&%4i@n4i==0 H for.Z&i=14Z@n4Z==0 H if.numWiX?numWZX0 H temp&numWiX4 numWiX&numWZX4 numWZX&temp4 L L L printf.I,8e sorted numbers in ascending order areNnI04 for.i&%4i@n4i==0 H printf.INnBdI,numWiX04 L getch.04 L

3#. Write a 2 program to calculate the factorial of given number *n+. ,he rules for calculating are if n?% calculate factorial, factorial&1, if n&% and if n@%, display the error message.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int n,i,fact&14 clrscr.04 printf.I7nter how many numbers$I04 scanf.IBdI,Kn04 if.n@%0 printf.I7>>E>3Ao factorail for n@%I04 else if.n&&%0 printf.I actorail&1I04 else H for.i&14i@&n4i==0 H fact&fact/i4 L printf.I actorial&BdI, fact04 L getch.04 L

3-. Aational book center decides to prepare a <ook 2lub. 9embers of the club are entitled to special discounts on the purchase of the book. ,he discount of 1"B is given to the members if purchase amount e!ceeds "%%% and 1%B is given it don+t e!ceed. Aon members aren+t normally given any discount. 8owever if their purchase e!ceeds >s. "%%%, a discount of #B is given. Write a 2 program to analyCe the above problem and find the net purchase amount.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H char ch4 int purchase4 C Solutions , 14

float dis,pamount4 clrscr.04 printf.I7nter UmU for members or UnU for non members$I04 scanf.IBcI,Kch04 printf.I7nter the purchase amount$I04 scanf.IBdI,Kpurchase04 switch.ch0 H case UmU$ if.purchase?"%%%0 dis&.purchase/%.1"04 else dis&.purchase/%.1%04 break4 case UnU$ if.purchase?"%%%0 dis&.purchase/%.%#04 else dis&%4 break4 default$ printf.I7nter the valid choice either m or n$I04 break4 L pamount&purchase3dis4 printf.IAet purhcase amount&BfI,pamount04 getch.04 L

31. Write a program to convert the line of lowercase te!t to uppercase te!t.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H char stringW1%%X4 clrscr.04 printf.I7nter a string$I04 scanf.IBsI,string04 printf.I6tring in uppercase&BsI,strupr.string004 getch.04 L

4%. Write a program to print integers from 1 to 1%% using W8)D7 loop
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int i4 clrscr.04 i&14 while.i@&1%%0 H printf.IBdNtI,i04 i&i=14 L getch.04 L

41. Write a program to calculate and print square of any given number.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int n4 clrscr.04 printf.I7nter a number$I04 scanf.IBdI,Kn04 printf.I6quare&BdI,n/n04 getch.04 L

42. Write a 2 program to display the sum of *n+ terms of even numbers.
C Solutions , 15

Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int i,n&%,num,sum&%4 clrscr.04 printf.I7nter the value of nI04 scanf.IBdI,Knum04 for.i&14i@&num4i==0 H sum&sum=n4 n&n=24 L printf.I6um&BdI,sum04 getch.04 L

43. Write a 2 program to calculate the factorial of a given number using function.
Ginclude @stdio.h? Ginclude @conio.h? int factorial.int04 void main.0 H int n,fact4 clrscr.04 printf.I7nter any numberI04 scanf.IBdI,Kn04 fact&factorial.n04 printf.Ifactorial&BdI,fact04 getch.04 L int factorial.int n0 H int i,fact&14 for.i&n4i?&14i330 H fact&fact/i4 L return fact4 L

44. Write a 2 program to print the first 1% terms of the following series using E> loop. 1, ", 1, 13, ;;.. .867<32%(30
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int i,n&14 clrscr.04 for.i&14i@&1%4i==0 H printf.IBd,I,n04 n&n=44 L getch.04 L

4". Write a 2 program to sort integer values in descending order. .867<32%(30


Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int i,Z,numW1%%X,n,temp4 clrscr.04 printf.I7nter how many numbers$I04 scanf.IBdI,Kn04 for.i&%4i@n4i==0 H printf.I7nter the number$I04 scanf.IBdI,KnumWiX04 L C Solutions , 16

for.i&%4i@n4i==0 H for.Z&i=14Z@n4Z==0 H if.numWiX@numWZX0 H temp&numWiX4 numWiX&numWZX4 numWZX&temp4 L L L printf.I,8e sorted integers in descending order areNnI04 for.i&%4i@n4i==0 H printf.INnBdI,numWiX04 L getch.04 L

4(. Write a 2 program to read the age of 4% students and count the number of students of the age between 1" and 2". .867<32%(30
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int i,n,count&%,ageW4%X4 clrscr.04 for.i&%4i@4%4i==0 H printf.I7nter the age of studentI04 scanf.IBdI,KageWiX04 L for.i&%4i@4%4i==0 H if.ageWiX?&1" KK ageWiX@&2"0 count&count=14 L printf.IAo of students having age in between 1" and 2" &BdI,count04 getch.04 L

4#. Write a 2 program to print the 1% positive integers and their factorials. .867<32%(20
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int i,Z4 long int fact4 clrscr.04 printf.IAumberNt actorialI04 for.i&14i@&1%4i==0 H printf.INnBdI,i04 fact&14 for.Z&i4Z?&14Z330 H fact&fact/Z4 L printf.INtBldI,fact04 L getch.04 L

4-. Write a 2 program to input *n+ numbers and find out greatest and smallest number. .867<32%(20
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int i,n,numW1%%X,largest,smallest4 C Solutions , 17

clrscr.04 printf.I7nter the value of nI04 scanf.IBdI,Kn04 for.i&%4i@n4i==0 H printf.I7nter any numberI04 scanf.IBdI,KnumWiX04 L largest&numW%X4 smallest&numW%X4 for.i&%4i@n4i==0 H if.largest@numWiX0 largest&numWiX4 if.smallest?numWiX0 smallest&numWiX4 L printf.IDargest number&BdI,largest04 printf.INn6mallest number&BdI,smallest04 getch.04 L

41. Write a 2 program to read in a positive integer less than 2% and display its multiplication table. .867<32%(20
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int i,num4 clrscr.04 printf.I7nter a positive integer less than 2%I04 scanf.IBdI,Knum04 if.num@2%0 H for.i&14i@&1%4i==0 H printf.INnBd/Bd&BdI,num,i,i/num04 L L else printf.I7nter the number less than 2% onlyI04 getch.04 L

"%. Write a 2 program to input the names of *n+ numbers of students and sort them in alphabetical order. .867<32%(20
Ginclude @stdio.h? Ginclude @conio.h? Ginclude @string.h? void main.0 H char nameW3%XW2"X,tempW2"X4 int i,Z,n4 clrscr.04 printf.I7nter how many studentsI04 scanf.IBdI,Kn04 for.i&%4i@n4i==0 H printf.INn7nter the name of the student$I04 scanf.IBsI,nameWiX04 L for.i&%4i@n4i==0 H for.Z&i=14Z@n4Z==0 H if.strcmp.nameWiX,nameWZX0?%0 H strcpy.temp,nameWiX04 strcpy.nameWiX,nameWZX04 strcpy.nameWZX,temp04 C Solutions , 18

L L L printf.I,he sorted names are$I04 for.i&%4i@n4i==0 H printf.INnBsI,nameWiX04 L getch.04 L

"1. Write a 2 program to read salaries of 2%% employees and count the number of employees getting salary between "%%% 3 1%%%%. .867<32%(20
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int salW2%%X,i,count&%4 clrscr.04 for.i&%4i@2%%4i==0 H printf.I7nter the salary$I04 scanf.IBdI,KsalWiX04 L for.i&%4i@2%%4i==0 H if.salWiX?&"%%% KK salWiX@&1%%%%0 count&count=14 L printf.IAo of employees getting salary between "%%%31%%%%&BdI,count04 getch.04 L

"2. Write a 2 program that will read successive records from the data file and display each record on the screen in an appropriate format. .867<32%(20
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H char nameW2"X4 char addressW2"X4 char telnoW2"X4 )D7 /fp4 clrscr.04 fp&fopen.IrecordI,IrI04 printf.IAameNt:ddressNt,elnoNnI04 while.fscanf.fp,IBsBsBsI,name,address,telno0V&7E 0 H printf.INnBsNtBsNtBsI,name,address,telno04 L fclose.fp04 getch.04 L

"3. Write a 2 program that reads different names and addresses into the computer and rearrange the names into alphabetical order using the structure variable. .867<3 2%(10 "4. Write a 2 program to display the multiplication table of series of given numbers entered by the user. .867<32%(10
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int n,i,Z,numW1%%X4 clrscr.04 printf.I7nter how many numbers of multiplication table to display$I04 scanf.IBdI,Kn04 for.i&%4i@n4i==0 H printf.I7nter the numbers$I04 scanf.IBdI,KnumWiX04 C Solutions , 19

L for.i&%4i@n4i==0 H for.Z&14Z@&1%4Z==0 H printf.INnBd/Bd&BdI,numWiX,Z,numWiX/Z04 L L getch.04 L

"". Write a program using 2 language to read the age of 1%% persons and count the number of persons in the age group between "% and (%. Fse the * or+ and *2ontinue+ statements. .867<32%(10
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H int ageW1%%X,count&%,i4 clrscr.04 for.i&%4i@1%%4i==0 H printf.I7nter the age of personI04 scanf.IBdI,KageWiX04 L for.i&%4i@1%%4i==0 H if.ageWiX?&"% KK ageWiX@&(%0 count&count=14 else continue4 L printf.IAo of persons in the age between "% and (%&BdI,count04 getch.04 L

"(. Write a 2 program to input a string and count the no of vowels in the string.
Ginclude @stdio.h? Ginclude @conio.h? Ginclude @string.h? void main.0 H char stringW2"X4 int count&%,i,length4 clrscr.04 printf.I7nter the string$I04 scanf.IBsI,string04 length&strlen.string04 for.i&%4i@length4i==0 H if.stringWiX&&UaUYYstringWiX&&UeUYYstringWiX&&UiUYYstringWiX&&UoUYYstringWiX&&UuU0 count&count=14 L printf.IAo of vowels&BdI,count04 getch.04 L

"#. Write a 2 program to write the name, address and telno in a data file and read the successive records to display them in the proper format.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H char nameW2"X4 char addressW2"X4 char telnoW2"X4 )D7 /fp4 clrscr.04 fp&fopen.IrecordI,IaI04 printf.INn7nter the name$I04 scanf.IBsI,name04 C Solutions , 20

printf.INn7nter the address$I04 scanf.IBsI,address04 printf.INn7nter the telno$I04 scanf.IBsI,telno04 fprintf.fp,INnBsNtBsNtBsI,name,address,telno04 fclose.fp04 fp&fopen.IrecordI,IrI04 printf.IAameNt:ddressNtNtNt,elnoNnI04 while.fscanf.fp,IBsBsBsI,name,address,telno0V&7E 0 H printf.INnBsNtBsNtBsI,name,address,telno04 L fclose.fp04 getch.04 L

"-. Write a 2 program to write *n+ persons name, address and telno in a data file and display them, reading the successive data from the file in proper format.
Ginclude @stdio.h? Ginclude @conio.h? void main.0 H char nameW2"X4 char addressW2"X4 char telnoW2"X4 )D7 /fp4 int i,n4 clrscr.04 fp&fopen.Irec.dataI,IaI04 printf.I7nter how many records$I04 scanf.IBdI,Kn04 for.i&%4i@n4i==0 H printf.INn7nter the name$I04 scanf.IBsI,name04 printf.INn7nter the address$I04 scanf.IBsI,address04 printf.INn7nter the telno$I04 scanf.IBsI,telno04 fprintf.fp,INnBsNtBsNtBsI,name,address,telno04 L fclose.fp04 fp&fopen.Irec.dataI,IrI04 printf.IAameNt:ddressNtNtNt,elnoNnI04 while.fscanf.fp,IBsBsBsI,name,address,telno0V&7E 0 H printf.INnBsNtBsNtBsI,name,address,telno04 L fclose.fp04 getch.04 L

"1.

C Solutions ,

21

Вам также может понравиться