Posts

My Subject Blog

C Program to Find Largest Odd Number from Array

/*  Write a Program to Find largest odd number from given 1-D Array. */ #include <stdio.h>      int main(void)  {   int a[10],i,n=10,max=0,j=0;     for(i=0;i<n;i++)     {     printf("Enter Value at a[%d] : ",i);     scanf("%d",&a[i]);     if(a[i]%2==1)     {     if(j==0)     {     max=a[i];     j++;     }     else     {     if(max<a[i])     {     max=a[i];     }     }     }     }     if(j==0)     {     printf("There is no Odd Value in Array");     }     else     {     printf(" Largest Odd value in Array is : %d",max);     }     return 0;  }

C Program for Display Sum and Average of Array Variable

/* Write a program to display Sum and average of any 10 no. using 1-D Array. */ #include <stdio.h> int main(void) { int a[10],i,n=10,sum=0; for(i=0;i<n;i++) { printf("Enter Value at a[%d] : ",i); scanf("%d",&a[i]); sum=sum+a[i]; } printf("\n SUM = %d",sum); printf("\n AVG = %d",sum/n); return 0; }

C Program for Pyramid and Pattern

/* Pattern Programs:(WAP to print pattern like below) *   *  *   *  *  *   *  *  *  *  */ #include <stdio.h> int main(void) { int i,j,n; printf("Enter How Many Rows You Want :"); scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<=i;j++) { printf("* "); } printf("\n"); } return 0; } /* Pattern Programs:(WAP to print pattern like below) 1  2 2  3 3 3  4 4 4 4 */ #include <stdio.h> int main(void) { int i,j,n; printf("Enter How Many Rows You Want :"); scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<=i;j++) { printf("%d ",i+1); } printf("\n"); } return 0; } /* Pattern Programs:(WAP to print pattern like below) 1   0 1   1 0 1   0 1 0 1 */ #include <stdio.h> int main(void) { int i,j,n; printf("Enter How Many Rows You Want :"); scanf("%d",&n); for(...

C Program Palindrome

/*  Write a program to find whether a number is palindrome or not.  */ #include <stdio.h> int main(void) { int no,sum=0,temp; printf("Enter Number : "); scanf("%d",&no); temp=no; while(no>0) { sum = (sum * 10)+(no % 10); no = no / 10; } if(temp == sum) { printf("\n %d is Palindrome",temp); } else { printf("\n %d is not Palindrome",temp); } return 0; }

C Program Calculator

/*   Write a program to make a simple calculator using switch..case statement.   */ #include <stdio.h> int main(void) { int a=10,b=20,ch; do { printf("\n================"); printf("\nSelect Operation"); printf("\n================"); printf("\n1 - Addition"); printf("\n2 - Substraction"); printf("\n3 - Multiplication"); printf("\n4 - Division"); printf("\n5 - Modulo"); printf("\n6 - Exit"); printf("\n================"); printf("\nEnter Your Choice :"); scanf("%d",&ch); printf("Enter First Value :"); scanf("%d",&a); printf("Enter Second Value :"); scanf("%d",&b); switch(ch) { case 1: printf("\nAnswer = %d",a+b); break; case 2: printf("\nAnswer = %d",a-b); break; case 3: printf("\nAnswer = %d",a*b); break; case 4: ...

C Program Find Minimum Value

/* Write a program to find minimum no out of three numbers by using Conditional Operator(nested..if ).  */ #include <stdio.h> int main(void) { int a,b,c; printf("Enter Three Values : "); scanf("%d %d %d",&a,&b,&c); printf("\n Minimum Value is : %d",((a<b)?(a<c?a:c):(b<c?b:c))); return 0; }

C Program Odd or Even

/*  Write a program to find out whether a number is odd / even by using different if..else statements.   */ #include <stdio.h> int main(void) { int n; printf(" Enter any Number :"); scanf("%d",&n); if(n%2==0) { printf("\n %d is Even",n); } else { printf("\n %d is Odd",n); } if(n&1==1) { printf("\n %d is Odd",n); } else { printf("\n %d is Even",n); } return 0; }

Followers