You are on page 1of 6

# 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

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

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

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

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

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