Posts

Showing posts from January, 2024
 import java.util.Scanner; class sumcalc {  int sum;  sumcalc() { sum=0; } sumcalc(int limit) { sum=calcsum(limit); }  int calcsum(int limit) { int result=0; for(int i=0;i<=limit;i++) { result+=i; } return result; } public void disrslt() { System.out.println("sum is ="+sum); } } class main { public static void main(String[]args) { Scanner obj=new Scanner(System.in); System.out.println("enter limit"); int limit=obj.nextInt(); sumcalc res=new sumcalc(limit); res.disrslt(); } }
 import java.util.Scanner; { class suncalc int sun; Suncalc(){ SUM=0; } suncalc(int limit) { Sum=calcsum(linit); } int calcsum(int limit) { int result=0; for(int i=0;i<=linit;i++) { result+=1; } return result; } public void disrslt() { System.out.println("sun is ="+SUR); } } class main { public static void main(String[]args) { Scanner obj=new Scanner(System.in); System.out.println("enter limit"); int limit=obj.nextInt(); suncalc res=new suncalc(linit); res.disrslth: } }
 #include<stdio.h> #include<stdlib.h> int top=-1,stacksize=9; char st[10]; int push(char value) {  if(top==stacksize-1)  {   printf("\n stack is full");   return 0;  }  else  {   top++;   st[top]=value;   return 1;  }  } char pop() {  if(top==-1)  {  printf("stack is empty");  //return 1;  }  else   return st[top--]; } char peek() {  if(top==-1)   {    //return -1;   }  else   {    return st[top];   } } int main() {  float value;  char postfix[20],cc,sopr,fopr,digit[20];  int i=0;  printf("enter the positive expression:");  scanf("%s",postfix);  while(postfix[i]!='\0')  {   cc=postfix[i];   if(cc=='+'||cc=='-'||cc=='*'||cc=='/')   {     sopr=pop();    fopr=pop();    switch(cc)    {     case'+':value=fopr+sopr;   ...
 #include<stdio.h> #include<ctype.h> int top=-1,stacksize=9; char st[10]; int push(char value) {  if(top==stacksize-1)  {   printf("\n stack is full");   return 0;  }  else  {   top++;   st[top]=value;   return 1;  }  } char pop() {  if(top==-1)  {  printf("stack is empty");  //return 1;  }  else   return st[top--]; } char peek() {  if(top==-1)   {    //return -1;   }  else   {    return st[top];   } } int main () {  int j=0,i=0;  char infix[20],postfix[20],cc,p;  printf("\n Enter the infix expresssion:");  scanf("%s",infix);  while(infix [i]!='\0')  {   cc=infix[i];   if(cc=='(')   {    push(cc);   }   else if (cc==')')   {    p=pop();    while(p!='(')    {     postfix[j]=p;     j++;     p=pop(); ...