Neeraj Mishra

A crazy computer and programming lover. He spend most of his time in programming, blogging and helping other programming geeks.

C++ program to add, subtract, multiply and divide two complex numbers using structures

#include<iostream.h> #include<conio.h> #include<math.h> struct complex { float rel; float img; }s1,s2; void main() { clrscr(); float a,b; cout<<“Enter real and imaginary part of 1st complex number:”; cin>>s1.rel>>s1.img; cout<<“Enter real and imaginary part of 2nd complex number:”; cin>>s2.rel>>s2.img; //Addition a=(s1.rel)+(s2.rel); b=(s1.img)+(s2.img); cout<<“nAddition: “<<“(“<<a<<“)”<<“+”<<“(“<<b<<“)”<<“i”; //Subtraction a=(s1.rel)-(s2.rel); b=(s1.img)-(s2.img); cout<<“nSubtraction: “<<“(“<<a<<“)”<<“+”<<“(“<<b<<“)”<<“i”; //Multiplication a=((s1.rel)*(s2.rel))-((s1.img)*(s2.img)); b=((s1.rel)*(s2.img))+((s2.rel)*(s1.img)); cout<<“nMultiplication: “<<“(“<<a<<“)”<<“+”<<“(“<<b<<“)”<<“i”; //Division a=(((s1.rel)*(s2.rel))+((s1.img)*(s2.img)))/(pow(s2.rel,2)+pow(s2.img,2)); b=(((s2.rel)*(s1.img))-((s1.rel)*(s2.img)))/(pow(s2.rel,2)+pow(s2.img,2)); …

C++ program to add, subtract, multiply and divide two complex numbers using structures Read More »

C program to concatenate two strings without using strcat() function

#include<stdio.h> #include<conio.h> void main() { char s1[30],s2[30],s3[60]; int i,j; clrscr(); printf(“Enter first string:”); gets(s1); printf(“Enter second string:”); gets(s2); for(i=0;s1[i]!=’’;++i) s3[i]=s1[i]; for(j=0;s2[j]!=’’;++j) s3[i+j]=s2[j]; s3[i+j]=’’; printf(“nThe concatenated string is: %s”,s3); getch(); }

Basic Structure of C Program

Here you will learn about basic structure of C program.   Any C program is consists of 6 main sections. Below you will find brief explanation of each of them. Basic Structure of C Program Documentation Section This section consists of comment lines which include the name of programmer, the author and other details like …

Basic Structure of C Program Read More »

Linear Search in C

Here you will find program for linear search in C. Linear search is the simplest searching algorithm which is sometimes known as sequential search. In this algorithm each element of array is compared with the targeted element sequentially. Linear Search in C #include<stdio.h> int main() { int a[20],i,x,n; printf(“How many elements?”); scanf(“%d”,&n); printf(“Enter array elements:\n”); …

Linear Search in C Read More »