C-programmingReversing an arrayC program to reverse an arrayThis program- reversing an array, reverses the order of the elements in an array. #include<stdio.h> #include<conio.h> void main() { int a[100],i,n; printf("enter no of elements"); scanf("%d",&n); printf("enter the elements of the array") for(i=0;i<=n;i++) scanf("%d",&a[i]); printf("elements in reversed order is ") for(i=n;i>=0;i--) printf("%d",a[i]); } Array of elements is got from the user through a for loop. Now using another for loop and by decrementing .. To find smallest number in an arrayC program to find smallest numberThis program finds the smallest of numbers #include<stdio.h> #include<conio.h> main() { int array[100], minimum, size, c, location = 1; printf("Enter the number of elements in array\n"); scanf("%d",&size); printf("Enter %d integers\n", size); for ( c .. To find largest number in an arrayC program to find largest numberThis program finds the largest number in a given array of numbers. #include<stdio.h> #include<conio.h> main() { int array[100], maximum, size, c, location = 1; printf("Enter the number of elements in array\n"); scanf("%d",&size); printf("Enter %d numbers\n", size); .. Armstrong number in CC program to find armstrong number#include Armstrong numbers are the sum of their own digits to the power of the number of digits. For example consider 153, where 1^3+5^3+3^3= 153. #include<conio.h> #include<conio.h> main() { int number, sum = 0, temp, remainder; printf("Enter a number\n"); scanf("%d",&number); .. To check whether the number is palindromeC program to check palindromeA palindromic number or numeral palindrome is a 'symmetrical' number like 1221, that remains the same when its digits are reversed. To check whether a number is palindrome or not first we reverse it and then compare the number obtained with the original, if both are same then number is palindrome .. Reversina a number in CC program for reversing a numberThis program reverses the given number. For example if user enter 78 as input then 87 is printed as output. Modulus operator is used for obtaining the digits one by one. #include<stdio.h> #include<conio.h> main() { int n, rev = 0; printf("Enter a number to reverse\n"); scanf("%d",&n); .. Swapping of numbers in cC program to swap 2 numbersThis C program is to swap two numbers with and without using third variable. Swapping is used in sorting process to arrange the numbers in particular order. SWAPPING USING TEMPORAL VARIABLE #include<stdio.h> #include<conio.h> main() { int x, y, temp; printf("Enter the value of x and y "); .. Addition of n numbersC program for adding n numbersThis c program add n numbers which will be entered by the user. #include<stdio.h> #include<conio.h> main() { int n, sum = 0, a, var; printf("Enter the number of integers for addition\n"); scanf("%d",&n); printf("Enter %d numbers\n",n); for ( a .. To check for vowelC program to find vowel or notThis code checks whether an input alphabet is a vowel or not. Both lower-case and upper-case are checked. #include<stdio.h> #include<conio.h> main() { char ch; printf("Enter a character\n"); scanf("%c",&ch); if ( ch .. String copy in cC program to copy stringsThis program copy string using library function strcpy. #include<stdio.h> #include<string.h> main() { char source[] = "C program"; char destination[50]; strcpy(destination, source); printf("Source string: %s\n", source); printf("Destination string: %s\n", destination); return 0; } output Source string: C program destination: C program .. String compare in cC program to compare stringsThis c program compares two strings using strcmp function. #include<stdio.h> #include<string.h> main() { char a[100], b[100]; printf("Enter the first string\n"); gets(a); printf("Enter the second string\n"); gets(b); if( strcmp(a,b) == 0 ) printf("Entered strings .. String concetenate in cC program to concatenate stringsThis program concatenates strings, for example if the first string is "hello" and second string is "world" then on concatenating these two strings we get the string "helloworld". To concatenate two strings we use strcat function of string.h. #include<stdio.h> #include<conio.h> #include<string.h> main() { char a[100], b[100]; printf("Enter the first .. String reverse in cC program to reverse a stringThis program reverses a string entered by the user. For example if a user enters a string "hello" then the reversed string will be "olleh". #include #include main() { char a[100]; printf("Enter a string to reverse\n"); gets(a); strrev(a); printf("Reversed string .. Program to find total salaryTo find total salary with If ElseThis program calculates the total salary of a person with IF-ElSE #include<stdio.h> #include<conio.h> void main () { long int sal,hra,ta,ts; clrscr (); printf ("Enter Salary: "); scanf("%ld",&sal); if (sal>=5000) { hra=sal*.10; ta=sal*.07; } else { hra=sal*.08; ta=sal*.05; } ts=sal+hra+ta; printf ("\n\nTotal Salary is Rs.%ld", ts); getch (); } output: Enter salary 2500 Total salary 2825 .. Fibonacci seriesTo generate fibonacci series for a given number#include "stdio.h" #include "conio.h" void main() { int a,b,c,i,n; clrscr(); a=0; b=1; printf("\n enter n value "); scanf("%d",&n); printf("\n FIBONACCI SERIES\n"); printf("\t%d\t%d",a,b); for(i=0;i<n;i++) { c=a+b; a=b; b=c; printf("\t%d",c); } getch(); } OUTPUT enter n value 5 FIBONACCI SERIES 0 1 1 2 3 .. |