Mohit

  • Uploaded by: Mohit
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Mohit as PDF for free.

More details

  • Words: 1,652
  • Pages: 33
Sum of two Numbers Input: #include<stdio.h> #include void main() { int a,b,c=0; clrscr(); printf("Enter first no."); scanf("%d",&a); printf("Enter second no."); scanf("%d",&b); printf("Sum is"); c=a+b; printf("%d",c); getch(); }

Output: Enter first no.5 Enter second no.5 Sum is10

Calculate Simple Interest Input: #include<stdio.h> #include void main() { float a,b,c,si=0; clrscr(); printf("Enter the value of Principal"); scanf("%f", &a); printf("Enter the value of Rate"); scanf("%f", &b); printf("Enter the value of time"); scanf("%f", &c); si=a*b*c/100; printf("Value of simple interest is" "%f",si); getch(); }

Output: Enter the value of Principal1000 Enter the value of Rate10 Enter the value of time30 Value of simple interest is3000.000000

Solve (ax+b)/(ax-b) Input: #include<stdio.h> #include #include<math.h> void main () { int a,b,x; float y=0; clrscr(); printf("Enter value of a, b & x"); scanf("%d%d%d",&a,&b,&x); y=((a*x)+b)/((a*x)-b); printf("%f",y); getch(); }

Output: Enter value of a, b & x 3 2 1 5.000000

Solve

2.5 log x-cos 30+|x2-y2|+sqrt (2xy)

Input: #include<stdio.h> #include #include<math.h> void main () { float x,y,z=0; clrscr(); printf("Enter value of x & y"); scanf("%f%f",&x,&y); z=(2.5*log(x))-(cos(30))+(abs(pow(x,2)-pow(y,2)))+(sqrt(2*x*y)); printf("%f",z); getch(); }

Output: Enter value of x & y10 5 90.602211

Solve x5+10x4+8x3+4x+2 Input: #include<stdio.h> #include #include<math.h> void main () { int x,y=0; clrscr(); printf("Enter value of x"); scanf("%d",&x); y=pow(x,5)+10*(pow(x,4))-8*(pow(x,3))+(4*x)+2; printf("%d",y); getch(); }

Output: Enter value of x1 9

ASCII Equivalent Input: #include<stdio.h> #include void main() { char a; clrscr(); printf("Enter a character\t"); scanf("%c",&a); printf("ASCII eqivalent is ::%d",a); getch(); }

Output: Enter a character a ASCII eqivalent is ::97

Basic arithmetic operations

Input: #include<stdio.h> #include void main() { int a,b,c; float r=0; clrscr(); printf("\t\t\t\tEnter value of a"); scanf("%d",&a); printf("\t\t\t\tEnter value of b"); scanf("%d",&b); printf("\t\t\t\tPress 1. to add\n"); printf("\t\t\t\tPress 2. to subtract\n"); printf("\t\t\t\tPress 3. to multiply\n"); printf("\t\t\t\tPress 4. to divide\n\t\t\t\t"); scanf("%d",&c); switch(c) { case 1: r=a+b; printf("\t\t\t\t%f",r); break; case 2: r=a-b; printf("\t\t\t\t%f",r); break; case 3: r=a*b; printf("\t\t\t\t%f",r); break; case 4: r=a/b; printf("\t\t\t\t%f",r); break; default: printf("\t\t\t\twrong choice");

} getch(); }

Output: Enter value of a5 Enter value of b6 Press 1. to add Press 2. to subtract Press 3. to multiply Press 4. to divide 3 30.000000

Sum of a G.P

Input: #include<stdio.h> #include #include<math.h> void main() { int n; float a,r,res=0; clrscr(); printf ("Enter first term"); scanf("%f",&a); printf("Enter Common Difference"); scanf("%f",&r); printf("Enter No. of Terms"); scanf("%d",&n); if(r>1) { res=a*((pow(r,n))-1)/(r-1); } else if (r<1) { res=a*(1-(pow(r,n)))/(1-r); } else { printf("Invalid Condition"); } printf("%f",res); getch(); }

Output: Enter first term2 Enter Common Difference2

Enter No. of Terms4 30.000000

Print the following output 1 2 3

2 3

3

4 5

4 5

4 5

4 5

5

. .

Input: #include<stdio.h> #include int main() { int i,j; clrscr(); for(i=1;i<=5;i++) { for(j=1;j<=i;j++) { printf("%d",i); printf("\t"); } printf("\n"); } getch(); }

Output: 1 2 3 4 5

2 3 4 5

3 4 5

4 5

5

To Find The Factorial Input:

#include<stdio.h> #include main() { int fact=1,no,i; clrscr(); printf("Enter a number to find factorial\t"); scanf("%d",&no); for(i=1;i<=no;i++) fact=fact*i; printf("\nThe factorial of %d is\t\t %d",no,fact); getch(); }

Output: Enter a number to find factorial 5 The factorial of 5 is 120

Basic Arithmetic Operations In Complex Number Input:

#include<stdio.h> #include #include<math.h> void add(); void sub(); void mul(); void div(); void display(); int a,b,c,d,x,y,ch; void main() { clrscr(); printf("\nEnter the value of a\t"); scanf("%d",&a); printf("\nEnter the value of b\t"); scanf("%d",&b); printf("\nEnter the value of c\t"); scanf("%d",&c); printf("\nEnter the value of d\t"); scanf("%d",&d); printf("\nThe first complex no. is %d+%di\n",a,b); printf("\nThe second complex no. is %d+%di\n",c,d); printf("\nEnter your choice\n 1)add \n 2)sub\n 3)Mul\n 4)div\n"); printf("\nThe choice entered by you is\t"); scanf("%d",&ch); switch(ch) { case 1: add(); break; case 2: sub(); break; case 3: mul(); break; case 4: div(); break;

default: printf("\nWRONG CHOICE!!!!!!!!!!"); } getch(); } void add() { x=a+c; y=b+d; printf("\nThe sum of complex no.is\t%d+%di",x,y); } void sub() { x=a-c; y=b-d; printf("\nThe diff of complex no.is\t%d+%di",x,y); } void mul() { x=((a*c)-(b*d)); y=((a*d)+(b*c)); printf("\nThe mul of complex no. is\t%d+%di",x,y); } void div() { x=((a*c)+(b*d))/((c*c)+(d*d)); y=((b*c)-(a*d))/((c*c)+(d*d)) ; printf("\nThe div of complex no. is\t%d+%di",x,y); }

Output: Enter the value of a 5 Enter the value of b 7 Enter the value of c 8 Enter the value of d 3 The first complex no. is

5+7i

The second complex no. is 8+3i Enter your choice 1)add 2)sub 3)Mul 4)div The choice entered by you is 2 The diff of complex no.is -3+4i

Sum of the series 1+1/2+1/3+1/4+___________+1/20 . .

Input: #include<stdio.h> #include void main()

{ float i,sum=0; clrscr(); for(i=1;i<=20;i++) { sum=sum+(1/i); } printf("The sum of the series 1 + 1/2 + 1/3 + 1/4 + ____________+ 1/20 is "); printf("%f",sum); getch(); }

Output: The sum of the series 1 + 1/2 + 1/3 + 1/4 + ____________+ 1/20 is 3.597740

Cipher a String Input: #include<stdio.h> #include #include<string.h>

int main() { int i,c; char a[30]; clrscr(); printf("Enter one string\t"); gets(a); c=strlen(a); for(i=0;i
Output: Enter one string Wyrs~

Mohit

Reverse a Number Input: #include<stdio.h> #include void main()

{ int i, b=0; clrscr(); printf("\nEnter the no. \t\t"); scanf("%d",&i); printf("\nReverse of the no. is\t"); while(i>0) { b=i%10; printf("%d",b); i/=10; } getch(); }

Output: Enter the no. 1989 Reverse of the no. is 9891

Count the Numbers of Digits Input: #include<stdio.h> #include void main() { int a,b,i=0; clrscr(); printf("\nEnter the digit\t"); scanf("%d",&a); do { b=a%10; i++; a/=10; } while(a>0); printf("\nNo. of digit is %d\t",i); getch(); }

Output: Enter the digit 5647 No. of digit is 4

Checking and Performing some operation on matrix Input: #include<stdio.h> #include #include<math.h> void upper(); void lower(); void symmetry(); void trace(); void transpose(); int a[10][10],b[10][10]; int i=0,j=0,s=0,m,n,ch; void main() { clrscr(); printf("\nEnter your choice\n\n 1)Upper triangular\n 2)Lower triangular\n 3)Symmetry\n 4)Trace\n 5)Transpose\n\n"); printf("\nChoice entered by you is\t"); scanf("%d",&ch); printf("\n"); printf("\nEnter no. of rows and columns of matrix\t"); scanf("%d%d",&m,&n); printf("\nEnter the element of matrix\t"); for(i=0;i<m;i++) { for(j=0;j
} printf("\n"); } printf("\n"); switch(ch) { case 1: upper(); break; case 2: lower(); break; case 3: symmetry(); break; case 4: trace(); break; case 5: transpose(); break; default: printf("\nWRONG CHOICE!!!!!!!!!!"); } getch(); } void upper() { printf("\nUpper trangular part is\n"); for(i=0;i<m;i++) { for(j=0;j
} printf("\n"); } getch(); } void lower() { printf("\nLower trangular part is\n"); for(i=0;i
} if(s==1) { printf("\nMatrix does not posses symmetry"); } else { printf("\nMatrix posses symmetry"); } getch(); } void trace() { int sum=0; for(i=0;i<m;i++) { for(j=0;j
{ printf("%d",b[i][j]); printf(" "); } printf("\n"); } getch(); }

Output: 1) Enter your choice 1)Upper triangular 2)Lower triangular 3)Symmetry 4)Trace 5)Transpose Choice entered by you is

1

Enter no. of rows and columns of matrix 3 3 Enter the element of matrix Matrix is 123 456 123 Upper trangular part is 123 56 3 2) Enter your choice 1)Upper triangular 2)Lower triangular 3)Symmetry 4)Trace 5)Transpose

123456123

Choice entered by you is

3

Enter no. of rows and columns of matrix 3 3 Enter the element of matrix

412153236

Matrix is 412 153 236 Matrix posses symmetry 3) Enter your choice 1)Upper triangular 2)Lower triangular 3)Symmetry 4)Trace 5)Transpose Choice entered by you is

4

Enter no. of rows and columns of matrix 3 3 Enter the element of matrix Matrix is 123 456 582 The trace of the matrix is8

123456582

Basic Operations on Matrix Input: #include<stdio.h> #include #include<math.h> void add(); void sub(); void mul(); int a[10][10],b[10][10],s[10][10]; int i=0,j=0,m,n,t,p,ch; void main() { clrscr(); printf("\nEnter your choice\n\n 1)add\n 2)sub\n 3)mul\n\n"); printf("\nChoice entered by you is\t"); scanf("%d",&ch); printf("\n"); printf("\nEnter no. of rows and columns of matrix\t"); scanf("%d%d",&m,&n); printf("\nEnter the element of first matrix\t"); for(i=0;i<m;i++) { for(j=0;j
{ for(j=0;j
printf(" "); } printf("\n"); } } getch(); } void add() { for(i=0;i<m;i++) { for(j=0;j
Output: 1) Enter your choice 1)add 2)sub 3)mul Choice entered by you is

1

Enter no. of rows and columns of matrix 3 3 Enter the element of first matrix

123456789

Enter the element of second matrix

987654321

First Matrix is 123 456 789 Second Matrix is 987 654 321 resultant matrix is 10 10 10 10 10 10 10 10 10

2) Enter your choice 1)add 2)sub 3)mul Choice entered by you is

3

Enter no. of rows and columns of matrix 3 3 Enter the element of first matrix Enter the element of second matrix First Matrix is 123 654 123 Second Matrix is 654 123 321 resultant matrix is 17 15 13 53 48 43 17 15 13

123654123 654123321

Linear search in an array Input: #include<stdio.h> #include #include<string.h> void linear(int a[50],int i); int a[50],n,i,t; void main() { clrscr(); printf("\nEnter number of element\t"); scanf("%d",&t); printf("\nEnter the elements of array\t"); for(i=0;i
else { printf("\nElement is not present in given array"); } getch(); }

Output: 1) Enter number of element 4 Enter the elements of array

1989

Enter the searching elements

8

Element present in given array 2) Enter number of element 5 Enter the elements of array Enter the searching elements

08915 4

Element is not present in given array

Related Documents

Mohit
April 2020 13
Mohit Resume
October 2019 14
Mohit Sen
June 2020 8
Mohit Final
May 2020 7
Mohit-cv
June 2020 5
Mohit[1].moni
December 2019 7

More Documents from ""

Session3_datafile.xlsx
December 2019 45
9th_nmcc (2).pdf
November 2019 29
Ces Notes - 29 05 07
October 2019 32
Task#84133.docx
May 2020 21