Posts

Showing posts from March, 2015

A C program to find a sum of series of polynomial

A C program to find the sum of series of polynomial #include<stdio.h> #include<math.h> void main() { int i,n,sum,a[20]; float x; printf(" enter the number of coefficients \n"); scanf("%d",&n); printf("enter the coefficients\n"); for("i=0;i<n;i++) { scanf("%d",&a[i]); } printf("enter the value for x\n"); scanf("%f",&x); sum=0; for(i=n-1;i>0;i--) { sum=sum+a[i]*pow(x,i); } printf("result is %d\n",sum); getch(); clrscr(); }

A Algorithm and Flowchat and Program for Bubble sort

Image
ALGORITHM Step 1: Start Step 2: [input] read n numbers Step 3: [for loop statement] Step 4:  for(i=1;i<n;i++) [loop for passing number] Step 5: for(j=0;j=n-i;j++) [loop for comparison] Step 6: [using if condition]              if(a[j]>a[j+1]) Step 7: [body of if condition]                { Step 8: temp=a[j];              a[j]=a[j+1];              a[j+1]=temp;               }               [end of if condition]               [end of step 5 j loop]               [end of step 4 i loop] Step 9: print the sorted numbers Step 10: Stop [end of the algorithm]

A C program to find square of a number using function

NO PARAMETER AND NO RETURN VALUE #include<stdio.h> void main() { square(); return; } void square() { int a,s; printf("\nenter a number\n"); scanf("%d",&a); s=a*a; printf("\nsquare of a number is= %d",s); return; }

A C program to find all arithmatic operations using function

#include<stdio.h> int sum(int a,int b) { int sum; sum=a+b; return sum; }

A C program to find addition of two array using fundtion

#include<stdio.h> arraysum(int x[10],int z[10]) { int i; for(i=0;i<10;i++) { arraysum=x[i]+z[i]; } return arraysum; }

A C program for Binary search using array

#include<stdio.h> int binarysearch(int a,int m,int n) { int u,mid,h; h=0; u=n-1; { while(1<=u) { mid=(h+u)/2; if(m==a[mid]) { c=1; break; } else if(m<a[mid]) { u=mid-1; } else h=mid+1; } return mid; }

Program to Sort the Elements using function

#include<stdio.h> void sort(int m,int x[ ]) { int i,j,t; for(i=1;i<=m-1;i++) { for(j=1;j<=m-i;j++) { if(x[j-1]>=x[j]) { t=x[j-1]; x[j-1]=x[j]; x[j]=t; } } }

C program check palindrome using function

#include<stdio.h> #include<string.h> char rev(str2) { char str1; strrev(str2); return (str2); } void main() { char str,a; printf("enter the string"); gets(str);  a=rev(str); if(a==str) printf("palindrome"); else printf("not a palindrome"); getch(); clrscr(); }

C Program for Fibonacci Series using Functions

#include<stdio.h> int fibo(int n) { int n,m,sum,i; i=1; n=0; m=1; while(i<=1) {

Multiplication of two matrix using User Defined Function

#include<stdio.h> #include<conio.h> void mul(int a[10][10],int b[10][10],int c[10][10],int m,int n,int p,int q) {  for(i=0;i<m;i++) for(j=0;j<q;j++) { c[i][j]=0; for(k=0;k<n;k++) c[i][j]=a[i][j]+p[i][k]*b[k][i]; } }

A C program to find factorial using a user defined function

#include < stdio.h > int fact(int n) {  int z=1;  for(; n>=1; n--)     z = z * n;   return (z); }

Program to find cube of a number using function

#include<stdio.h> int cube(int a) { int cube; cube=(a*a*a); return cube; } void main() { int x; x=cube(x); printf("Cube=%d",x); getch(); clrscr(); }

C program to find square using User Defined Function

#include<stdio.h> int square(int a) { int square; square=(a*a); return square; } void main() { int x; x=square(x) Printf("square= %d",x); getch(); clrscr(); }

Difference between CHARACTERS and STRING

*)A Character is a single character enclosed within single quote like 'a','e' But a string is a set of character  stored in consecutive locations in memory and terminated by null character. For example "harish" *)A character constants has an equivalent integer value. A string character string constant does not have an equivalent integer value

A c program to find a prime numbers for a given range

#include<stdio.h> void main() { int i,n1,n2; printf("\nEnter the range\n"); scanf("%d%d",&n1,&n2); for(i=n1;i<=n2;i++) { if(isprime(i)) printf("%d",i); } getch(); clrscr(); } int isprime(int m) { int i; for(i=2;i<=m/2;i++) { if(m%i==0) { retuen 0; } } return 1; }

A C program to find row sum and coloum sum of a matrix

#include<stdio.h> #include<conio.h> void main() {      int i,j,k,A[10][10],R[10],C[10],m,n;      clrscr();      printf(" ENTER THE SIZE OF A MATRIX \n");      scanf("%d%d",&m,&n);     printf("ENTER THE ELEMENT OF A MATRIX \n");     for(i=0;i<m;i++) {  for(j=0;j<n;j++) {    scanf("%d",&A[i][j]); } }      for(i=0;i<m;i++)      {  R[i]=0;  for(j=0;j<n;j++)  R[i]=R[i]+A[i][j];      } for(i=0;i<n;i++) {  C[i]=0;  for(j=0;j<m;j++) C[i]=C[i]+A[j][i]; } for(i=0;i<m;i++) {   for(j=0;j<n;j++) {      printf("%4d",A[i][j]);   printf("%8d",R[i]);   printf("\n"); } } printf("\n");    for(j=0;j<n;j++) {    printf("%4d",C[j]); } getch();    }

A C program to Find Transpose of a Matrix

#include<stdio.h> #include<conio.h> void main() { int A[10][10] , B[10][10], i, j;                                    printf("\nenter the values for m&n"); scanf("%d%d,&m,&n); printf(" Enter the elements of A\n"); for(i=0 ; i<m ; i++) { for(j=0 ; j<n ; j++) { scanf("%d" , &A[i][j] ); } } printf(" Matrix is\n"); for(i=0 ; i<m ; i++) { for(j=0 ; j<n ; j++) { printf("%d\t" , A[i][j] );                            }                                                            printf("\n");                                        } for(i=0 ; i<m ; i++) { for(j=0 ; j<n ; j++) { B[i][j] = A[j][i]; } } printf(" After Transpose\n"); for(i=0 ; i<m ; i++) { for(j=0 ; j<n ; j++) { printf("%d\t" , B[i][j] );                             }                                                           

Volkswagen Hover Car: Are Flying Cars The Model Of The Future?

Image
When Volkswagen invited its customers to think up some ideas, it was perhaps inevitable that there would be at least one flying car design put forward. But one concept – the ‘Hover Car’ – impressed the firm so much a short CGI YouTube video was made to showcase it. The video bellow shows a VW flying two-seater zipping through Beijing. The car, powered by minerals underground, was the brainchild of a girl in China who responded to the carmaker’s call for car innovation concepts. The idea is that thrusters on the back of the car would propel it forward. Getting the “car” to work for real would require electromagnetic strips embedded into the roads below it, creating the hovering effect via electromagnetic suspension. As a prize, the girl’s parents got to “test drive” the car in a simulated video. According to  Creativity Online , VW received 119,000 ideas and got 33 million hits on its website.

A C program to find Addition of 2 matrix using 2-D array

#include <stdio.h>   void main ( ) { int m , n , c , d , first [ 10 ] [ 10 ] , second [ 10 ] [ 10 ] , sum [ 10 ] [ 10 ] ;   printf ( "Enter the number of rows and columns of matrix \n " ) ; scanf ( "%d%d" , & m , & n ) ; printf ( "Enter the elements of first matrix \n " ) ;   for ( c = 0 ; c < m ; c ++ ) { for ( d = 0 ; d < n ; d ++ ) { scanf ( "%d" , & first [ c ] [ d ] ) ; }   } printf ( "Enter the elements of second matrix \n " ) ;   for ( c = 0 ; c < m ; c ++ ) { for ( d = 0 ; d < n ; d ++ ) { scanf ( "%d" , & second [ c ] [ d ] ) ; } }   printf ( "Sum of entered matrices:- \n " ) ;   for ( c = 0 ; c < m ; c ++ ) { for ( d = 0 ; d < n ; d ++ ) { sum [ c ] [ d ] = first [ c ]

A C program to find mean, variance and standard deviation

Image
#include <stdio.h> #include <math.h> void main ( ) { float x [ MAXSIZE ] ; int i , n ; float average , variance , std_deviation , sum = 0 , sum1 = 0 ;   printf ( "Enter the value of N \n " ) ; scanf ( "%d" , & n ) ; printf ( "Enter real numbers \n " ) ; for ( i = 0 ; i < n ; i ++ ) { scanf ( "%f" , & x [ i ] ) ; } for ( i = 0 ; i < n ; i ++ ) { sum = sum + x [ i ] ; } average = sum / n ; for ( i = 0 ; i < n ; i ++ ) { sum1 = sum1 + pow ( ( x [ i ] - average ) , 2 ) ; } variance = sum1 / n ; std_deviation = sqrt ( variance ) ; printf ( "Average of all elements = %f \n " , average ) ; printf ( "variance of all elements = %f \n " , variance ) ; printf ( "Standard deviation = %.2f \n " , std_deviation )