Follow

# Did you have a favorite OITNB character before you joined the cast?

View Full Interview# Write a program to find sum of two numbers in c language without using variables?

include"stdio.h" int main ( int argc, char *argv[ ] ) { if(argc == 2) printf("Sum of Two Numbers: %d \\r\\n", atoi( argv[1] ) + atoi( argv[2] ) ); else printf( "In-v…alid number of arguments !! \\r\\n" ); return 0; } Regards, Lakshmi Sreekanth

# C program to find sum of two sparse matrices?

#include #include typedef struct node { int column; int value; int row; … struct node *next; } element; /* MENU */ void Menu() { printf("\\n***\\tADDING SPARSE MATRICES\\t***\\n"); printf("\\n 1.) Insert in A"); printf("\\n 2.) Insert in B"); printf("\\n 3.) Printout both"); printf("\\n 4.) A + B = "); printf("\\n 0.) EXIT"); printf("\\nChoose ---------> "); } /* Initialize*/ void Init (element *x[]) { int i; for (i=0; ivalue); test = 1; temp = temp->next; } } if (test 0) printf("This matrix is empty!!\\n"); } /* INSERT */ void Insert(element *x[], int row, int column, int value) { int r = row; element *p; element *new = malloc(sizeof(element)); new->row = row; new->column = column; new->value = value; if (x[r] NULL) { x[r] = new; new->next = NULL; } else { p = x[r]; if (new->column < p->column) { new->next = p; x[r] = new; } else if (new->column > p->column) { while (p->next != NULL && p->next->column < new->column) { p = p->next; } new->next = p->next; p->next = new; } else printf("An element already exists there!!\\n"); } } /* A + B */ void Add (element *x[],element *y[],element *z[]) { int i; element *p, *q; for (i=0; icolumn, q->value); q = q->next; } } /*row of y empty, row of x not*/ if (x[i] != NULL && y[i] NULL) { q = x[i]; while (q != NULL) { Insert(z, i, q->column, q->value); q = q->next; } } /*row of x and y not empty*/ if (x[i] != NULL && y[i] != NULL) { p = x[i]; q = y[i]; /*stay in while loop until one row runs out*/ while (p != NULL || q != NULL) { /*columns match*/ if (p->column == q->column && p != NULL && q != NULL) { Insert(z, i, p->column , p->value + q->value); p = p->next; q = q->next; } /*column of x is smaller than column of y*/ else if (p->column < q->column) { Insert(z, i, p->column , p->value); p = p->next; } /*column of x is bigger than column of y*/ else { Insert(z, i, q->column , q->value); q = q->next; } } /*if row of x had more elements and didn't run out*/ if (p != NULL) { while (p != NULL) { Insert(z, i, p->column , p->value); p = p->next; } } /*if row of x had more elements and didn't run out*/ if (q != NULL) { while (q != NULL) { Insert(z, i, q->column , q->value); q = q->next; } } } } Printout(z); } /* FREE MEMORY*/ void Freedom (element *x[]) { int i; element *p; for (i=0; inext; free(p); } } } /* MAIN */ int main (int argc, const char * argv[]) { int choice, column, row, value, number; element *a[3], *b[3], *sum[3]; Init(a); Init(b); Init(sum); do { Menu(); scanf("%d",&choice); switch (choice) { case 1: /*Insert in A */ do { printf("Enter row -> "); scanf("%d",&row); } while (row < 0 || row > 3); do { printf("Enter column -> "); scanf("%d",&column); } while (column < 0); printf("Enter value -> "); scanf("%d",&value); Insert(a,row,column,value); break; case 2: /*Insert in B */ do { printf("Enter row -> "); scanf("%d",&row); } while (row < 0 || row > 2); do { printf("Enter column -> "); scanf("%d",&column); } while (column < 0); printf("Enter value -> "); scanf("%d",&value); Insert(b,row,column,value); break; case 3: /* Printout A & B */ printf("\\n::::::: MATRIX A :> \\n\\n"); Printout(a); printf("\\n::::::: MATRIX B :> \\n\\n"); Printout(b); break; case 4: /* A + B */ Init(sum); printf("\\n::::::: MATRIX A + B :> \\n\\n"); Add(a,b,sum); break; default: printf("\\nWRONG CHOICE"); } } while (choice != 0); Freedom(a); Freedom(b); Freedom(sum); return 0; }

# Write a c program to get a 5 digit number as input and find the sum of the digit using recursion?

Something like this: http://codepad.org/ua952rap

# Write c program to find sum of two numbers?

/*use "c-free" compiler*/ #include main() { int a,b,c; printf("enter the value of a & b"); scanf("%d%d",&a,&b); c=a+b; printf("sum of the two numbers is a+b- %d",c); g…etch(); }

# Write a c program to find the sum of digit of a given number?

for (digsum= 0; n!=0; digsum+=n%10, n/=10);

# How do you find the sum in c language?

include #include void main() { clrscr(); int a,b,sum; printf("Enter two nos."); scanf("%d%d",&a,&b); sum=a+b; printf("Sum is = %d",sum); getch(); }…

# C program to find sum of digits of a number using function?

#include #include void main() { int sumdig(int); int n,sum,d,f,rev=0; clrscr(); printf("enter the number"); scanf("%d",&n); sum=sumdig(n); printf("%d",sum)…; getch(); } int sumdig(int n) { int sum,d,r=0; if(n==0) return(0); else sum=n%10+sumdig(n/10); while(sum!=0) { d=sum%10; r=r+d; sum=sum/10; } return(r); }

# C program for sum of first and last digit of a number?

/*this v'll work to obtain sum of 1st and last number of any number */ #include int main() { int num,sum=0,i,fd,ld; printf("enter the number); scanf("%d",&num); ld…=n%10; //will get the last digit while(num!=0) { fd=n; n/10; //to get the 1st digit } sum=fd+ld; //add 1st n last digit printf("\\n sum of 1st n last digit is %d",sum) }

# A program to find sum of digits repeatedly until a single digit is obtained?

include #include main() { int n,s=0,sum=0,i,d; printf("enter the number"); scanf("%d",&n); while(n>0) { d=n%10; s=s+d; n=n/10; } while(s>0) { i=s…%10; sum=sum+i; s=s/10; } printf("%d",sum); getch(); }

# C program to find the sum of the digits of a number?

Here You go........... # include # include void main() { int no,sum=0,rem=0; clrscr(); printf("\\nEnter a Number: "); scanf("%d",&no); while(no>0) { rem=no%10; sum=sum+rem; n…o=no/10; } printf("\\nSum of digits of a number: %d",sum); getch(); }

# How do you write a c program to find the sum of five numbers?

The core of it would be something like this: int a,b,c,d,e,s; ... s=a+b+c+d+e;

# Write a c program to find the sum of the digits of a number?

include int sumOfDigit(int x){ int ans = 0; while(x>0){ ans += (x%10); x /= 10; } return ans; } int main(void){ printf("%d",sumOfDigit(12)); return 0; …}

Answered

# What is c program that will find the sum of square of the number?

I m writing only logic u should code it int x,y,z; printf("enter two numbers"); scanf("%d%d",&x,&y); z=x*x+y*y; printf("%d",z);

Answered

# C program to find the sum of odd positioned digits and even positioned digits of a number seperately?

include #include main() { int n,s,r,t; clrscr(); printf("enter n"); scanf("%d",&n); s=0;t=0; while(n!=0) { r=n%10; { if(r%2!=0) t=t+r; if(r%2==0) s=s+r; } n=n/10; } printf("s…um of even position digits%d\\n",s); printf("sum of odd position digits%d\\n",t); getch(); }

Math and Arithmetic Supervisor

In Technology

# Program to find sum of two numbers in VB.NET language?

Option Explicit Dim a as integer Dim b as integer Dim c as integer Dim result as integer a=val(text1.text) b=val(text2.text) c=val(text3.text) result=a+b+c '…now we want to push the result to another text box ,below code insert into the button click event text4.text=result text1.text="" text2.text="" text3.text="" Rename the cmd button As sum. And run the program by pressing F5 key.

Answered

# Java program to find the sum of digit of a number and reverse it?

public SumRevInt(String args) { System.out.println("in constr"); if(args == null) { System.out.println("hello, enter a choice during execution"); } else { char…[] ch = args.toCharArray(); System.out.println("add(digits)="+add(ch)); System.out.println("rev(digits)="+rev(ch)); } } static int add(char[] num) { int t=0; for(int i=0;i=0;i++) { s += String.valueOf(num[i]); } return Integer.parseInt(s); } public static void main(String[] args) { myObj = new SumRevInt(args[0]); }

Answered Most Recently

In Technology

# Write a program to find the sum of the digits and reverse of the digits using inheritance?

There is a far easier way to implement the required functionality than using inheritance. However, to answer the question, here's one possible solution that makes use of inher…itance: #include #include #include #include // In order to make use of inheritance we need a common base class. // Although the underlying datatype is an integral, we cannot inherit from an integral, // therefore we need to embed the integral in the base class, and provide operators // that allow the class to function as if it were an integral. Only the bare minimum // implementation required to achieve the goal is provided. class integral_t { friend std::ostream& operator