Blog

C Program to Find Given Integer is Positive or Negative

include main(){int num;printf(“Enter a Number to test ZERO or +ve or -ve :”);scanf(“%d”,&num);if(num==0)printf(“Entered Number is ZERO”);elseif(num>0)printf(“%d is a Positive Number”,num);elseprintf(“%d is a Negative Numbr”,num);}OUTPUT: Enter a Number to test ZERO or +ve or -ve :1010 is a Positive Number

Start reading C Program to Find Given Integer is Positive or Negative

C Program to Check Given Number is PRIME or Not

main(){    int n, i;    printf(“Enter an Integer Number to Find PRIME or Not  : “);    scanf(“%d”, &n);    for(i=2; i<=n/2; ++i)     {         if(n%i==0)         {             break;         }     }     if(i>n/2)        printf(“%d is PRIME”,n);    else        printf(“%d is NOT PRIME”, n);} OUTPUT: Enter an Integer Number to Find PRIME or Not : 2323 is PRIME

Start reading C Program to Check Given Number is PRIME or Not

C Program to Check Whether a Number is PALINDROME or Not

include main(){int no, digit = 0, temp;printf(“Enter an Integer to check for Palindrome : “);scanf(“%d”,&no);temp = no;while( temp != 0 ){digit = digit * 10;digit = digit + temp%10;temp = temp/10;}if ( no == digit )printf(“\n %d is a Palindrome Number :)\n”, no);elseprintf(“\n %d is Not a Palindrome Number :(“, no);} OUTPUT: Enter an Integer …

Start reading C Program to Check Whether a Number is PALINDROME or Not

Finding GCD and LCM of Given Numbers using C

 Finding GCD and LCM include int main(){    int no1, no2, rem=0, n1,n2;    printf(“Enter Two Non-Zero Integer Mumbers:”);    scanf(“%d%d”,&no1,&no2);    n1=no1;    n2=no2;    rem=no1%no2;    while(rem != 0)    {        no1=no2;        no2=rem;        rem=no1%no2;    }    printf(“\n GCD of %d and %d is %d”, n1,n2,no2);    printf(“\n LCM of %d and %d is %d”,n1,n2,(n1*n2)/no2);    return 0;} OUTPUT: Enter Two Non-Zero Integer Mumbers:15 25GCD of 15 and 25 is 5LCM of 15 and 25 is 75

Start reading Finding GCD and LCM of Given Numbers using C

C Program to Implement Structure with Array

include struct student{char name[20];int rollno;float marks;};struct student s1[3];void main(){int i;printf(“Enter Name, RollNo, and Marks of Three Students:\n”);//Reading Student detailsfor(i=0; i<=2; i++)scanf(“%s %d %f”,&s1[i].name,&s1[i].rollno,&s1[i].marks); } OUTPUT:Enter Name, RollNo, and Marks of Three Students:John 123 88Ravi 256 97Raj 214 94Student Name Student Rollno Student Marks:John 123 88.00Ravi 256 97.00Raj 214 94.00

Start reading C Program to Implement Structure with Array

C Program to Solve Tower of Hanoi Problem Using Recursive and Non-Recursive

/* Write C programs that use both recursive and non-recursive functionsTo solve Towers of Hanoi problem.*/ include include /* Non-Recursive Function/ void hanoiNonRecursion(int num,char sndl,char indl,char dndl) { char stkn[50],stksndl[50],stkindl[50],stkdndl[50],stkadd[50],temp; int top,add; top=NULL; one: if(num==1) { printf(“\nMove top disk from needle %c to needle %c “,sndl,dndl); goto four; } two: top=top+1; stkn[top]=num; stksndl[top]=sndl; stkindl[top]=indl; stkdndl[top]=dndl; …

Start reading C Program to Solve Tower of Hanoi Problem Using Recursive and Non-Recursive

C Program to Search an Array Element using BINARY SEARCH

include void binary_search(); int a[50], n, item, loc, beg, mid, end, i;void main(){printf(“\nEnter size of an array: “);scanf(“%d”, &n);printf(“\nEnter elements of an array in sorted form:\n”);for(i=0; i<n; i++)scanf(“%d”, &a[i]);printf(“\nEnter ITEM to be searched: “);scanf(“%d”, &item);binary_search();getch();}void binary_search(){beg = 0;end = n-1;mid = (beg + end) / 2;while ((beg<=end) && (a[mid]!=item)){if (item < a[mid])end = mid – …

Start reading C Program to Search an Array Element using BINARY SEARCH

C Program to Implement Structure with Pointers

include struct student{char name[30];int rollno;float marks;};void display(struct student *);void main(){struct student s1 = {“Raja”, 538, 92};display(&s1);getch();}void display(struct student *ptr){printf(“Student name\tRollno\tMarks\n”);printf(“%s\t\t%i\t%f”,ptr->name,ptr->rollno,ptr->marks);} OUTPUT:Student name Rollno MarksRaja 538 92.000000

Start reading C Program to Implement Structure with Pointers

C Program to Implement Structure with Functions

include struct student{char name;int rollno;float marks;};struct student std_func(char, int, float);main(){struct student s1 = {‘X’, 125, 95};std_func(s1.name, s1.rollno, s1.marks);getch();}struct student std_func(char name, int rollno, float marks){printf(“Name\tRoll No.\tMarks\n”);printf(“%c\t%d\t\t%.2f”, name, rollno, marks);} OUTPUT:Name Roll No. MarksX 125 95.00

Start reading C Program to Implement Structure with Functions