www.vidyarthiplus.

com

UNIVERSITY PROGRAMS
1. Write a program to convert years into 1. Minutes 2. Hours 3. Months and 5. Seconds, using switch statement. #include <stdio.h> #include <conio.h> void main() { long ch, min, hrs,ds, mon, yrs, se; clrscr(); printf(“\n \t Menu”); printf(“\n \1.MINUTES \N 2.HOURS\n 3.DAYS”); printf(“\n 4. MONTHS \n 5. SECONDS \n 6. EXIT”); pritf(“\n Enter your choice:”); scanf(“%d”, &ch); mon = yrs*12; ds = mon*30; hrs = ds*24; min = hrs*60 se = min*60; switch (ch) { case 1: printf(“\n Minutes: %d”, min); break; case 2: printf(“\n Hours: %d”,hrs); break; case 3: printf(“\n Days: %d”, ds); break; case 4: printf(“\n Months: %d”, mon); break; case 5: printf(“\n Seconds: %d”, se); break; case 6: exit (0); default: print (“\n Invalid choice”); } getch(); } Output: Menu 1. MINUTES 2. HOURS 3. DAYS 4. MONTHS 5. SECONDS 6. EXIT

h> # include <conio. Write a program to calculate factorial of a given numbers. 2. j+1). &x). j++) { gotoxy(p. for (i=1-j. } Output: Enter the number: 5 120. # include <stdio.www. 4.fact).h> # include <conio. a--. p = 34. j<=x. clrscr(). i++) printf(“%2d”. } getch(). } printf(“%d”. while(a> = 1) { fact = fact *a. printf(“\n Enter the Numbers: “). [Ex: 0 1 1 2 3 5…] #include<stdio. scanf(“%d”. for(j=0. # include <stdio.h> void main() { int a. &a). Write a program to evaluate the Fibonacci series. printf(“\n Enter a Number: “). scanf(“%d”. Write a program to generate the pyramid structure using numbers.h> . p = p-3. } Output: Enter a Number: 2 0 1 0 1 2 1 0 1 2 3. clrscr().vidyarthiplus. fact =1. i<=j. getch().h> void main() { int i.abs (i)).com Enter your choice: 4 Enter years: 2 Months:24.jx.

. j).h> void main() { chartext 1 [30]. Write a C program using pointer to read in an array of integers and print its elements in reverse order.www. scanf(“%d”. } void fibo(int r) { it i =0. j= f. clrscr(). text2 [30].com #include<conio. #include <stdio.vidyarthiplus. printf(“Enter the number range :”). k++) { f = i+j.h> #include<string. } } Output: Enter the number range : 5 FIBONACCI SERES : 0 1 1 2 3 5. getch(). k. printf(“%d %d”. Write a program to append second string with specified (n) number of characters at end of the first string using strcat() function. getch(). k< = r. for(k = 2. text1). I. print(“\n Enter Number of characters to Add:”). printf (“%d”. n.text2. printf(“\n FIBONACCI SERIES :”). puts(“Enter text 1:”). strcat(text1. gets(text2).h> void main() { int r.j = i. putes(“Enter text 2”). strcat(text1. j). 5. printf(“%s\n”. &r). fibo().n).h> #include<conio. gets(n). “ “).f. gets (text 1). } Output: Enter text1 : MAY I Enter text2 : COME IN? Enter Number of character to Add : MAY I COME IN? 6. i= j.

arr[MAX]. ptr=&arr[0]. } getch(). ptr++.c. ptr). i<size. scanf(“%d”. i--) { printf(“\n Element%d is %d :”. if(n % 2= = 0) printf(“Number is Even”). i> =0.h> #define MAX 30 void main() { int size. scanf(“%d”. i. . printf(“\nEnter %d integers into array: \n. ptr--.h> main() { int n. else printf(“Number is odd”). Program To Read Three Numbers And Print The Biggest Of Given Three Numbers # include <stdio.b. for(i=0. clrscr( ). 8.big=0. Write a C program to print given number is even or odd. i. int *ptr. printf(“Enter the number :”).h> main( ) { int a. } 7. clrscr(). *ptr).www. } printf(“\n Elements of array in reverse order are:\n_.h> # include <conio.vidyarthiplus. } Output 1: Enter the number : 15 Number is Odd. printf(“Enter the size of array: “). Output 2: Enter the number : 12 Number is Even. for(i=size-1. i++) { scanf(“%d”.h> #include <conio.com # include <stdipo. &n). /* This program identifies whether number is even or odd */ #include <stdio. size). &size).

a. print(“ENTER VALUE FOR C:”).&b). Program to accept a string and check the given string is palindrome or not . c. getch( ).i<=0.h> main( ) { int n.h> # include <conio.lim. d. if (n= =d) printf (“The Given Number is Armstrong number”).vidyarthiplus. c=n%10. &n). Program to accept a number and check the given number is Armstrong or not. clrscr( ). if (c>big) big=c. for(i=0. scanf(“%d”. printf(“ enter a string”). printf(“ENTER VALUE FOR B:”). # include <stdio.&a). scanf (“%d”. lim=i-1. clrscr( ). # include <stdio. b. printf (“BIGGEST OF ABOVE GIVEN THREE NUMBER IS %d”. a=n/100.i++. if(b>big) big=b. } 9.h> main( ) { int i. } 10.i++). scanf(“%d”. scanf(“%d”.check=1. for(i=0. printf (“ Enter a Three Digit Number: “). else printf (“The Given Number is Not Armstrong number”). char word[80]. .com printf(“ENTER VALUE FOR A:”).&c).www. d=a*a*a*+b*b*b +c*c*c.i<80 && ((word [i]= getchar())!=’\n’). c=lim/2. if (a>big) big=a .c. b=((n/10)%10).big) getch( ).lim--) if(word[i]!= word[lim]) { check=0.h> # include <conio.

else printf(“ not palindrome”). } . } if(check= =1) printf(“the given string is palindrome “).com break.vidyarthiplus.www. getch( ).

Sign up to vote on this title
UsefulNot useful