Easy Programming All

Easy Programming All

Wednesday, December 19, 2018

WAP in C to print a triangular pattern 2

December 19, 2018 0
WAP in C to print a triangular pattern 2
#include<stdio.h> int main() { int i, j, k; for(i = 1; i <= 5; i++) { k = 1; for(j = 1; j <= 5; j++) { if(j >= i) { printf("%d",k); k++; } else { printf(" "); } } printf("\n"); } return 0; } OUTPUT: ...

WAP in C to print a triangular pattern

December 19, 2018 0
WAP in C to print a triangular pattern
#include<stdio.h> int main() { int i, j, k; for(i = 1; i <= 5 ; i++) { k = 1; for(j = 1; j <= 5; j++) { if(j <= 5-i) { printf(" "); } else { printf("%d",k); k++; } } printf("\n"); } return 0; } OUTPUT: ...

Tuesday, December 18, 2018

WAP in C to print an array in reverse order

December 18, 2018 0
WAP in C to print an array in reverse order
#include<stdio.h> int main() { int a[100], n, i; printf("Enter number of elements, you want to insert in an array\n"); scanf("%d",&n); printf("Enter array elements\n"); for(i = 0; i < n; i++) scanf("%d",&a[i]); printf("Array in Reverse Order is:\n"); for(i = n-1; i >= 0; i--) printf("%d ",a[i]); return 0; } INPUT: Enter number of elements, you want to insert in an array 5 Enter array elements 11 22 33 44 55 OUTPUT:  Array in...

WAP to print Fibinacci Serien upto nth term

December 18, 2018 0
WAP to print Fibinacci Serien upto nth term
#include<stdio.h> int main() { int n, i, first = -1, second = 1, third; printf("Enter nth term to print Fibonacci Series\n"); scanf("%d",&n); printf("Fibonacci Series is:\n"); for(i = 1; i <= n; i++) { third = first + second; printf("%d ",third); first = second; second = third; } return 0; } INPUT : Enter nth term to print Fibonacci Series 8 OUTPUT : Fibonacci Series is: 0 1 1 2 3 5 8 13 ...

WAP in C to Sort an Array in Descending Order

December 18, 2018 0
WAP in C to Sort an Array in Descending Order
#include<stdio.h> int main() { int a[100], n, i, j, temp; printf("Enter number of elements, you want to insert in array\n"); scanf("%d",&n); printf("Enter Array Elements\n"); for(i = 0; i < n; i++) scanf("%d",&a[i]); for(i = 0; i < n-1; i++) { for(j = i+1; j < n; j++) { if(a[i] < a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } printf("After Sorting Array is:\n"); for(i = 0; i < n; i++) printf("%d ",a[i]); return 0; } INPUT: Enter...

WAP in C to Sort an Array in Ascending Order

December 18, 2018 0
WAP in C to Sort an Array in Ascending Order
#include<stdio.h> int main() { int a[100], n, i, j, temp; printf("Enter number of elements, you want to insert in array\n"); scanf("%d",&n); printf("Enter Array Elements\n"); for(i = 0; i < n; i++) scanf("%d",&a[i]); for(i = 0; i < n-1; i++) { for(j = i+1; j < n; j++) { if(a[i] > a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } printf("After Sorting Array is:\n"); for(i = 0; i < n; i++) printf("%d ",a[i]); return 0; } INPUT: Enter...

WAP in C to Delete an element from an Array

December 18, 2018 0
WAP in C to Delete an element from an Array
#include<stdio.h> int main() { int i, n, position, a[100], item; printf("How many Array Element you want to Enter\n"); scanf("%d " ,&n); printf("Enter an Array Elements\n"); for(i=0; i<n; i++) scanf("%d ", &a[i]); printf("which element you want to delete\n"); scanf("%d" , &item); for(i = 0; i <  n; i++) { if(a[i] = = item) { position = i; break; } } if( i = = n) { printf("Element can not find in this array"); } else { for(i...

WAP in C to insert an element to an array at given position

December 18, 2018 0
WAP in C to insert an element to an array at given position
#include<stdio.h> int main() { int i, a[100], n, item, position; printf("How many array elements you want to enter\n"); scanf("%d", &n); printf("Enter an array elements\n"); for(i = 0; i<n; i++) scanf("%d", &a[i]); printf("which position you want to insert an element\n"); scanf("%d", &position);          //Here position is array Index Number printf("Enter new array Element to insert\n"); scanf("%d",&item); if(position...

Monday, December 17, 2018

WAP in C to check Whether a given Number is Krishnamurthi or Not

December 17, 2018 0
WAP in C to check Whether a given Number is Krishnamurthi or Not
#include<stdio.h> int main() { int i, n, fact, sum = 0, copy, rem; printf("Enter any positive integer number to check Krishnamurthi or Not\n"); scanf("%d",&n); copy = n; while(n > 0) { rem = n % 10; fact = 1; for(i = 1; i <= rem; i++) fact = fact * i; sum = sum + fact; n = n / 10; } if(copy = = sum) { printf("%d given Number is Krishnamurthi",copy); } else { printf("%d  Number is Not Krishnamurthi",copy); } return 0; } INPUT 1: Enter...

WAP in C to check Whether a given Number is Armstrong or Not

December 17, 2018 0
WAP in C to check Whether a given Number is Armstrong or Not
#include<stdio.h> #include<math.h> int main() { int i, n, sum = 0, rem, copy, count = 0; printf("Enter any integer number to check armstrong or not\n"); scanf("%d",&n); copy =  n; while(n > 0) { count  =  count + 1; n = n / 10; } n = copy; while(n > 0) { rem = n % 10; sum = sum + pow(rem, count); n = n/10; } if(copy = = sum) { printf("The given %d number is Armstrong",copy); } else { printf("The...
Page 1 of 3123Next