Skip to main content

Posts

ACTIVE AND PASSIVE VOICE ENGLISH GRAMMER VTU ENGINEERING

Implement Recursive functions for Binary to Decimal Conversion Program and Algorithm Computer Science Engineering VTU

Binary to Decimal conversion  #include<stdio.h> #include<stdlib.h> int dec=0; int bintodec(int num,int x,int base); void main() { int num,n,r,x=0,base=1; printf("enter a binary number\n"); scanf("%d",&n); num=n; while(n>0) { r=n%10; if(r>1) { printf("enter a proper binary number\n"); exit(0); } x++; n=n/10; } bintodec(num,x,base); printf("decimal value of %d is %d\n",num,dec); } int bintodec (int num,int x,int base) { if(x==0) return 0; else dec=dec+(num%10)*base; bintodec(num/10,x-1,base*2); } Algorithm Binary to Decimal conversion Algorithm : Binary to Decimal conversion Start Declare the required variables Read binary number as n If n has digits...

Develop a program using pointers to compute the sum, mean and standard deviation of all elements stored in an array of N real numbers Program and Algorithm Computer Science Engineering VTU

pointers #include <stdio.h> #include <math.h> void main() { float a[10], *ptr, mean, sum=0, std,sumstd=0; int n,i; printf("Enter the number of elements : "); scanf("%d",&n); printf("Enter the array elements :\n"); for( i=0; i<n; i++) scanf("%f",&a[i]); //assigning address of a to pointer ptr ptr = a; //compute the sum for(i=0;i<n;i++) { sum += *ptr; ptr++; } //compute the mean mean = sum/n; //compute standard deviation ptr = a; for(i=0; i<n; i++) { sumstd = sumstd + pow((*ptr-mean),2); ptr++; } std = sqrt(sumstd/n); //print sum, mean, & standard deviation printf("Sum = %f\n",sum); printf("Mean = %f\n",mean); printf("Standard Deviation : %f\n",std); } POINTERS Algorithm   Start Read number of element...

Implement structures to read, write and compute average- marks and the students scoring above and below the average marks for a class of N students Program and Algorithm Computer Science Engineering VTU

Structures abov below avg #include<stdio.h> struct student { char name [100]; char usn [20]; float marks; }; void main() { int i,j,k,m,n,aboveavg[100],belowavg[100]; float total=0.0,avg=0.0; struct student s[100]; printf("enter number of students\n"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter the details of students%d\n",i+1); printf("enter name\n"); scanf("%s",s[i].name); printf("enter usn\n"); scanf("%s",s[i].usn); printf("enter marks\n"); scanf("%f",&s[i].marks); total+=s[i].marks; } printf("enter the details of students\n"); printf("name\t\t usn\t\t marks\n"); for(i=0;i<n;i++) printf("%s\t\t %s\t\t %f\n",s[i].name,s[i].usn,s[i].marks); avg=total/n; printf("avg=%f\n",avg); j=0; k=0; for(i=0;i<n;i++) { if(s[i].marks>avg) abov...

Write functions to implement string operations such as compare, concatenate, string length. Convince the parameter passing techniques Program and Algorithm Computer Science Engineering VTU

STRINGconcatenation #include<stdio.h> #include<stdlib.h> int length (char str[]); int compare (char str1[],char str2[]); void concatenate (char str1[],char str2[]); void main() { char str1[30],str2[30]; int choice,a,i,j; printf("enter 1-string comparision\n"); printf("enter 2-string length\n"); printf("enter 3-string concatenation\n"); printf("enter 4-exit\n"); scanf("%d",&choice); switch(choice) { case 1:printf("enter string 1\n"); scanf("%s",str1); printf("enter string 2\n"); scanf("%s",str2); a=compare(str1,str2); if(a==0) { printf("%s and%s are identical\n",str1,str2); } else { printf("%s and%s are not identical\n",str1,str2); } break; ...

Sort the given set of N numbers using Bubble sort Program and Algorithm Computer Science Engineering VTU

Bubble sort #include<stdio.h> int main() { int i,j,n,a[100],temp; printf("enter the number of elements"); scanf("%d",&n); printf("enter the elements\n"); for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<n-1;i++) { for(j=0;j<n-i-1;j++) { if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } printf("sorted arry\n"); for(i=0;i<n;i++) printf("%d\t",a[i]); return 0; } Algorithm: BubbleSort Start read n for i= 0 to n-1 read a[i] for i=0 to n-1 for j=0 to n-i-1 if (a[j] > a[j+1]) temp = a[j] a[j] = a[j+1] a[j+1] = temp for i=0 to n-1 print a[i] Stop