Posts

Showing posts from 2017

Stack using Arrays

Implement Stack using Arrays: Required Knowledge: C basics, Arrays Program: 1 #include<stdio.h> 2 #define SIZE 10 3 4 void push ( int ); 5 void pop (); 6 void display (); 7 8 int stack [ SIZE ], top = - 1 ; 9 10 void main () 11 { 12 int value , choice ; 13 while ( 1 ) 14 { 15 printf ( "\n\n***** MENU *****\n" ); 16 printf ( "1. Push\n2. Pop\n3. Display\n4. Exit" ); 17 printf ( "\nEnter your choice: " ); 18 scanf ( "%d" ,& choice ); 19 switch ( choice ) 20 { 21 case 1 : 22 printf ( "Enter the value to be insert: " ); 23 scanf ( "%d" ,& value ); 24 push ( value ); 25 break ; 26 case 2 : 27 pop (); 28 break ; 29 case 3 : 30 display (); 31 break ; 32 ca...

C Program to Search element in Array

Image
Write a C Program to Search element in Array: Required Knowledge: C basics, Arrays Program: 1 #include <stdio.h> 2 void main () 3 { 4 int arr [ 5 ], i , search ; 5 6 printf ( " Enter element: " ); 7 8 for ( i = 0 ; i < 5 ; ++ i ) 9 { 10 scanf ( "%d" ,& arr [ i ]); 11 } 12 printf ( "\n Enter the number you want to search:" ); 13 14 scanf ( "%d" ,& search ); 15 16 for ( i = 0 ; i < 5 ; i ++) 17 { 18 if ( search == arr [ i ]) 19 { 20 printf ( "\n\nThe number %d is at location:%d" , search , i + 1 ); 21 break ; 22 } 23 } 24 if ( search != arr [ i ]) 25 printf ( "\nNot found" ); 26 27 28 } 29 Output:

C Program to find average of the Arrays Elements

Image
Write a C Program to find average of the Arrays Elements: Required Knowledge: C basics, Arrays Program: 1 #include<stdio.h> 2 void main () 3 { 4 int n [ 5 ], i ; 5 int average , sum ; 6 7 for ( i = 0 ; i <= 4 ; i ++) 8 { 9 printf ( "Enter the number %d:" , i + 1 ); 10 11 scanf ( "%d" ,& n [ i ]); 12 } 13 14 sum = n [ 0 ]; 15 16 for ( i = 1 ; i <= 4 ; i ++) 17 { 18 sum = sum + n [ i ]; 19 20 average = sum / n [ i ]; 21 } 22 printf ( "average is:%d" , average ); 23 } Output:

C Program to find sum of the Arrays Elements.

Image
Write a C Program to find sum of the Arrays Elements: Required Knowledge: C basics, Arrays Program: 1 #include<stdio.h> 2 void main () 3 { 4 int n [ 5 ], i ; 5 int sum ; 6 7 for ( i = 0 ; i <= 4 ; i ++) 8 { 9 printf ( "Enter the number %d:" , i + 1 ); 10 11 scanf ( "%d" ,& n [ i ]); 12 } 13 14 sum = n [ 0 ]; 15 16 for ( i = 1 ; i <= 4 ; i ++) 17 { 18 sum = sum + n [ i ]; 19 } 20 21 printf ( "Sum is:%d" , sum ); 22 } Output:

C program to Delete an Element in Array at any location

Image
Write a  C program to Delete an Element in Array at any location: Required Knowledge: C basics, Arrays Program: 1 #include<stdio.h> 2 void delete ( int ); 3 int static size = 5 ; 4 int arr [ 5 ]; 5 void main () 6 7 { 8 int i , position , e , d ; 9 printf ( "Enter the elements of array:\n" ); 10 for ( i = 0 ; i < size ; i ++) 11 scanf ( "%d" ,& arr [ i ]); 12 13 printf ( "\nThe elements are:" ); 14 for ( i = 0 ; i < size ; i ++) 15 printf ( "%d " , arr [ i ]); 16 17 printf ( "\nEnter the index no to delete the element:" ); //index no start from 0 18 scanf ( "%d" ,& d ); 19 20 delete ( d ); 21 } 22 23 void delete ( d ) 24 { 25 int i ; 26 for ( i = d - 1 ; i < size - 1 ; i ++) 27 { 28 arr [ i ]= arr [ i + 1 ]; 29 30 } 31 size --; 32 printf ( "\nThe ele...

C Program to Insert Element in Array

Image
Write a  C program to Insert element in Array at any position: Required Knowledge: C basics, Arrays Program: 1 #include<stdio.h> 2 void insert ( int , int ); 3 int static size = 5 ; 4 int arr [ 5 ]; 5 void main () 6 7 { 8 int i , position , e , d ; 9 printf ( "Enter the elements of array:\n" ); 10 for ( i = 0 ; i < size ; i ++) 11 scanf ( "%d" ,& arr [ i ]); 12 13 printf ( "\nThe elements are:" ); 14 for ( i = 0 ; i < size ; i ++) 15 printf ( "%d " , arr [ i ]); 16 17 18 printf ( "\nEnter the position to insert an element:" ); 19 scanf ( "%d" ,& position ); //position according to index no 20 21 printf ( "\nEnter the element to insert:" ); 22 scanf ( "%d" ,& e ); 23 24 insert ( position , e ); 25 26 } 27 28 29 void insert ( position , e ) 30 { 31 32 ...

C program to Create an Array and Print it Elements

Image
Write a  C program to Create an Array and Print it Elements: Required Knowledge: C basics, Arrays Program: 1 #include<stdio.h> 2 3 void main () 4 { 5 int array [ 5 ]; 6 7 int i ; 8 9 for ( i = 0 ; i <= 4 ; i ++) 10 { 11 printf ( "Enter the number %d:" , i + 1 ); 12 scanf ( "%d" ,& array [ i ]); 13 } 14 15 printf ( "The numbers you entered are:\n" ); 16 17 for ( i = 0 ; i <= 4 ; i ++) 18 19 { 20 printf ( "%d\n" , array [ i ]); 21 } 22 23 } Output: Enjoy it........

C program for Grading System

Image
Write a C program for Grading System to Calculate the Grade of a Student: Required Knowledge: C Basics, If-else 1 #include<stdio.h> 2 void main () 3 { 4 int marks ; 5 6 printf ( "Enter student marks:" ); 7 8 scanf ( "%d" ,& marks ); 9 10 if ( marks >= 80 ) 11 12 printf ( "Grade of student is A" ); 13 14 else if (( marks <= 79 )&&( marks >= 70 )) 15 16 printf ( "Grade of student is B" ); 17 18 else if (( marks <= 69 )&&( marks >= 60 )) 19 20 printf ( "Grade of student is C" ); 21 22 else if (( marks <= 59 )&&( marks >= 50 )) 23 24 printf ( "Grade of student is D" ); 25 26 else 27 28 printf ( "Grade of student is F" ); 29 } Output: Enjoy It......

Print square using Printf statement

Image
Write a C Program to  Print square using Printf statement Required Knowledge: Fundamentals of C,printf statement E:\University work\semester 1\fcp\blog.c 1 #include<stdio.h> 2 void main () 3 { 4 printf ( "The printing of Square through printf staement:\n\n" ); 5 6 printf ( " ********* \n" ); 7 printf ( " * * \n" ); 8 printf ( " * * \n" ); 9 printf ( " ********* \n" ); 10 }

C program check whether a number is even or odd

Image
Write a C program to check whether a number is even or odd. Example:   Enter no: 2  Output: No is even Enter no: 9  Output: No is odd Required knowledge: Fundamentals of C, Data types, Taking user input in C, IF-else 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 /*****************************************************   * C program to check a number is positive or not *   *****************************************************/ #include <stdio.h> void main() {      int num;        /* Reads number from user */      printf ( "Enter any number to check even or odd: " );      scanf ( "%d" , &num);             /* Check if the number is divisible by 2 then it is even */ ...