Skip to main content

Posts

Showing posts from 2018

replacing strings without using inbuild functions

 Q:replacing strings without using inbuild functions. We are using gcc compiler and terminal to compile the code and ubuntu OS. PROGRAM: #include<stdio.h> int strln1(char s1[]); int strln2(char s2[]); void strcpy1(char s1[],char s2[]); int main() {     char s1[30],s2[30];     int result1,result2;     printf("Enter the string s1");     scanf("%s",s1);     printf("Enter the string s2");     scanf("%s",s2);     printf("Your string s1 is %s",s1);     printf("\nYour string s2 is %s",s2);     result1=strln1(s1);     result2=strln2(s2);     printf("\nlength of string s1 is %d\n",result1);     printf("\nlength of string s2 is %d\n",result2);     strcpy1(s1,s2); } int strln1(char s1[]) {     int i,ln;         ln=0;     i=0;     while(s1[i]!='\0')     {         i++;         ln++;     }     return ln; } int strln2(char

create a program to print directory strucure like C:\cygwin\home\administrator.

Q: Create a program that uses escape sequence \\ to print the following directory structure C:\cygwin\home\administrator. We are using gcc compiler and terminal to compile the code and ubuntu OS.   PROGRAM: #include<stdio.h> void main()  {   printf("C:\\cygwin\\home\\administrator.\n");  }  OUTPUTE:

Create a program to print quotes like "Dreams And Dedications Are Most Powerful Combinations" .

Q:Create a program that uses escape sequence \* to print your favorite quote   We are using gcc compiler and terminal to compile the code and ubuntu OS.   PROGRAM: #include<stdio.h>  void main()  {  printf("\"Dreams And Dedications Are Most Powerful Combinations\"\n");  }    OUTPUTE: 

Creating Diamond By Using Prinf() Statement

Q:Write a program that prints a diamond as demonstrated.                                             *                                   *                  *                          *                                      *                                   *                  *                                                 * We are using gcc compiler and terminal to compile the code and ubuntu OS.   Program: #include<stdio.h> void main() {  printf("\t\t\t*\n\n\n");  printf("\t\t*\t\t*\n\n\n");  printf("\t*\t\t\t\t*\n\n\n");  printf("*\t\t\t\t\t\t*\n\n\n");  printf("\t*\t\t\t\t*\n\n\n");  printf("\t\t*\t\t*\n\n\n");  printf("\t\t\t*\n\n\n"); }   OUTPUTE:  

Creating Calculator Program Using Cpp

Implement a class Complex which represents the Complex Number data type. Implement the following operations: 1. Constructor (including a default constructor which creates the complex number 0+0i). 2. Overloaded operator+ to add two complex numbers. 3. Overloaded operator* to multiply two complex numbers. 4. Overloaded << and >> to print and read Complex Numbers. We are using g++ compiler and terminal to compile the code and ubuntu OS.  PROGRAM: #include<iostream> using namespace std; int main() {  PROGRAM:    int a,b,c;    char op,d;    do    {    cout<<"Enter the first number:";    cin>>a;    cout<<"Enter the second number:";    cin>>b;    cout<<"Enter operator +,-,*,/:";    cin>>op;       switch(op)       {        case'+':          c=a+b;          cout<<"Addition:"<<a<<"+"<<b<<"="<<c;          break;        case'